Hi Guys,
I have a strange thing going on with my code and I'm stumped as to why this is happening.
I have several word variables:
B_PWM
B_MAX
B_MIN
The values of two of these are set as follows:
B_MAX= 4095
B_MIN= 0
I then have several case statements that are selected using the "IF THEN" statements
The case statement is thus (I've removed nested IF THEN statements within the statement just in case that was causing the issue)
So basically, if the condition is matched where the counter = blue on time and B_PWM is less than B_MAX then the case DAWN is selected. This works, but for some reason when B_PWM = 4095 the cycle doesn't change the DAY as it should. After a lot of trial and hair pulling (it's already gone grey trying to suss this out) I manages to get it to change, to DAY when the B_MAX was removed and changed for hard value
I added some diagnostics options to the LCD so I could see what's going on and displaying the decimal value for B_MAX Im getting 65535 which would explain the reason why it was ignoring the comparison as B_PWM would have to equal 65535, but why isn't B_MAX equalling 4095 when the value is set to 4095 in the first part of the code?
The reason I'm looking for a range of 0 - 4095 is I'm using an external PWM chip which has 4095 resolution
I have a strange thing going on with my code and I'm stumped as to why this is happening.
I have several word variables:
B_PWM
B_MAX
B_MIN
The values of two of these are set as follows:
B_MAX= 4095
B_MIN= 0
I then have several case statements that are selected using the "IF THEN" statements
Code:
if counter1 => blue_on_time and B_PWM < B_MAX then
Blue_day_cycle = DAWN
endif
Code:
case DAWN
lcdout $FE,$80+15,"DAWN "
if pcaPwmValue0 => blue_delay_in then
B_PWM=B_PWM+1
pcaPwmValue0 = 0
endif
if B_PWM => 4095 then
B_PWM=4095
endif
if B_PWM=4095 then
Blue_Day_Cycle = DAY
endif
Code:
if counter1 => blue_on_time and B_PWM < 4095 then
Blue_day_cycle = DAWN
endif
The reason I'm looking for a range of 0 - 4095 is I'm using an external PWM chip which has 4095 resolution