Getting data from user, compare it with sensor data, turn off/on power according to result of comparison


Getting data from user, compare it with sensor data, turn off/on power according to result of comparison



Help!



I'm kind of a beginner in assembly, using atmelstudio7 working on micro controller atmega168A.
explanation of what I want: I defined program to get the min temperature from user. And compare it with the current temperature, if the Min temp. is lower turn off the power( RF in code).



Problem:



I don't know how to call current temperure, WHICH varible should I call to get the number of current temp.? what should I call to read the number of current temp.
The code of current temperature is here:


show_temp: call append_space ;add a space character
ldi XH, 02
clr xl
rcall spit16_TC72 ;read temperature sensor, answer in temp2

cvt_temp: mov zl, temp2 ;provide reading value in temp2
sbrc temp2, 7
rjmp neg_temp
tpout: clr zh
rcall d3ascii
ret
neg_temp: neg zl ;take 2's complement
ldi temp2, '-' ;show negative
call append_char ;zl not touched
rjmp tpout

vbrs_temp: ldi temp, msg_temp ;===TEMPERATURE=======
rcall send_msg_colon_sp ;temp
rcall show_temp ;temperature
ldi temp, msg_celsius
jmp send_msg_cr_lf ;temperature



now my code for getting data from user:


act101: rcall query_check ;spit out auto response (if no parm given)
Tflag=0
brtc act1010rsp ;check T flag (if no parm given) Tflag=0
sts TE_MINH, cmdhbyt
sts TE_MINL, cmdlbyt

act1010rsp: ldi yh, high (TE_MINH)
ldi yl, low (TE_MINH)

spitatemp: ld ZH, y+
ld ZL, y+
call d3ascii
call comp_MIN
ret



( I have a problem with calling mintemp for the first time too, when I type mintemp( in order to get the last mintemp typed in terminal )the out put is: mintemp Z35??
where does it come from? I want to have the last typed min temp.



THE MAIN PROBLEM: comparing and turning off power if the user mintemp is lower


comp_MIN: lds temp, spit16_TC72 ; current temperture.
lds temp2, act1010rsp ; user temperture
cp temp2, temp
brge putrfoff_
putrfoff_: cbi PORTC, PC_PA_ONOFF
ret



I don't know if spit16_TC72 is correct for calling to read the current temp or not and where is the user typed min temp? calling act1010rsp is correct?
why turn off ( putrfoff_) the power does not work?



Thanks in advance.




1 Answer
1



THE MAIN PROBLEM: comparing and turning off power if the user mintemp is lower



The problem in comp_MIN is the branch. Either if it's taken or not, the instruction 'vbi PORTC, PC_PA_ONOFF' is executed (fallthrough)


comp_MIN: lds temp, spit16_TC72 ; current temperture.
lds temp2, act1010rsp ; user temperture
cp temp2, temp
brge putrfoff_
putrfoff_: cbi PORTC, PC_PA_ONOFF
ret



you can fix this e.g. like this:


comp_MIN: lds temp, spit16_TC72 ; current temperture.
lds temp2, act1010rsp ; user temperture
cp temp2, temp
brlt no_change_
cbi PORTC, PC_PA_ONOFF
no_change_: ret



I don't know how to call current temperure, WHICH varible should I call to get the number of current temp.? what should I call to read the number of current temp.



reading your code, I'd say


rcall spit16_TC72 ;read temperature sensor, answer in temp2



but this for sure can better re answered by the guy you copied the code from, since he seems to know the setup and the circuit. we can only guess that





Thank you for your answer but it still does not work.
– pari
Jul 3 at 18:48





and we'll not be able to help you ANY further with just this (incomplete) snippet you gave us. As I said, you better ask the guy who gave you that code
– Tommylee2k
Jul 4 at 6:02






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

JMeter fails on beanshell imports

Why in node-red my HTTP POST no receive payload from inject?

PHP contact form sending but not receiving emails