PDA

View Full Version : PIC18F452 and problem with if statement



Stephan P.
- 5th July 2006, 10:13
Morning,
I write something to the memory and read it later, compare it and change it if it is necessary. My problems are now this commands:

scale0_min = ERead 30
If scale0_min < -100000 Then scale0_min = 0 'look if scale_min is stored
If scale0_min >= 100001 Then scale0_min = 0
scale0_max = ERead 34
If scale0_max < -100000 Then scale0_max = 100 'look if scale_max is stored
If scale0_max >= 100001 Then scale0_max = 100

scale1_min = ERead 38
If scale1_min < -100000 Then scale1_min = 0 'look if scale_min is stored
If scale1_min >= 100001 Then scale1_min = 0
scale1_max = ERead 42
If scale1_max < -100000 Then scale1_max = 100 'look if scale_max is stored
If scale1_max >= 100001 Then scale1_max = 100

scale2_min = ERead 46
If scale2_min < -100000 Then scale2_min = 0 'look if scale_min is stored
If scale2_min >= 100001 Then scale2_min = 0
scale2_max = ERead 50
If scale2_max < -100000 Then scale2_max = 100 'look if scale_max is stored
If scale2_max >= 100001 Then scale2_max = 100

wanted to make it easier with IF.. THEN.. ELSEIF... THEN... ENDIF. When i do that the PIC is reseting the whole time. Also when i use IF... OR ... THEN. Program usually with C so maybe it is just not possible to do it like that.
If someone can tell me whats going on i will be very happy.

Stephan

Acetronics2
- 5th July 2006, 10:22
Hi,

Did you remember PbP " classic " number input and output range is 0 - 65535 ( 16 Bits ) ??? for negative values you could use ABS () care your number do not exceed 15 bits. see manual for explanation.

Multiple IF Then s ... can be replaced by the SELECT CASE command ...

Note that's an answer for PBP using !!! I think you're not exactly using PBP ... so, may be you're not on the bestForum to get the right answer ...

Alain

mister_e
- 5th July 2006, 14:09
Alain is right. I guess you use PROTON.


It remind me something so far... if you set the Watchdog timer you may have to use

WATCHDOG = 0

But i can be wrong to, i saw few new update for that one so, if you're using the latest upgrade, it shouldnt, hum hum, give you some problem. Anyways i've never use that one too long to have great solution.

The best place for you is bellow
www.picbasic.org/forum

Stephan P.
- 5th July 2006, 14:14
Yes i am using proton, sorry for that. Go to the other forum.

THX Stephan