Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

voltage difference

Status
Not open for further replies.

pouchito

New Member
Hi Dudes :)

need your help please

I m doing a project using PIC (any PIC) that have to read 2 voltages V1 and V2.
then will subtract V2-V1 which will result a value called :difference

Compare the "difference" to some values (i think i must create a table here)

for example if 1<difference < 2 output " correct" on a LCD

I am new to picbasic pro and i need your help to write this code in the subtraction and comparison Parts.

Thanks in advance
 
Last edited:
See device under test datasheet. There you find all without need to go outside what it tells you to do.

Cblock 0x20 (you Know The Story)
Value1, Value2, Difference
Table:10
Endc


;configure Ports
;configure Adc
;turn This On
;turn That Off


Call Initialize_lcd
Main:

Call Capture_adc
Call Get_difference
Call Update_lcd

End_main


;-----------------------
Capture_adc
;see Device Datasheet
Return
;------------------------

;------------------------
Get_difference:
Movf Value1, W
Subwf Vaue2, W
Movwf Difference
Return
;-------------------------

;-------------------------
Update_lcd:
Movf Difference, W
Subwf Table+x, W
Btfss Status, Z
Goto Show_fail
Goto Show_pass

Show_pass
Call Lcd_send_pass
Goto Update_lcd1

Show_fail
Call Lcd_send_fail
Goto Update_lcd1

Update_lcd1
;do Any Other Stuff
Return
;--------------------------
 
Last edited:
donniedj said:
Call Initialize_lcd
Main:

Call Capture_adc
Call Get_difference
Call Update_lcd

End_main

;-------------------------
Update_lcd:
Movf Difference, W
Subwf Table+x, W
Btfss Status, Z
Goto Show_fail
Goto Show_pass

What language is that?

Mike.
 
pouchito said:
isn't this assembly??? :confused:

Sorry if I confused you, the above code is mainly assembler but with some misleading syntax in it. The Main ... End_Main is not a valid way to write the main loop and the Subwf Table+x,W instruction suggests that some form of indexed addressing mode is available. I just think this example code is confusing.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top