bug in piecewise linear table (by David R)
HI Jonathan
I think there is A bug in how the pic processes the piecewise linear table.
The output does not match the table but it is ok when in Simulation.
here is the out put from the pic:
raw data 890
output 25
raw data 890
output 25
the output in Simulation is 29 which is right as the maths is square root.
Regards
David.
(no subject) (by Juan)
Hi David,
I tested you're program by scaling an analogue input from 0-2046, and using a pot to test the graph output. Everything works perfectly on my PC as I move from 0 to full on a 5V rail. I'm using a PIC16F88 with a PICKIT 3 programmer.
(no subject) (by Jonathan Westhues)
This turns out to be a subtle bug in the PIC16 add and subtract routines. They generated incorrect results when a carry or borrow (across the byte boundary) occurred and destination and B operand were the same.
The piecewise linear table would generate an expression of the form B = A - B, which sometimes fails.
Attached find a test build with that bug corrected. Let me know if that works, or if you still see any problems.
(no subject) (by David R)
HI,
it looks ok I have feed several different value through and the result is correct.
Thanks
David.