Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - bug in piecewise linear table

(you are viewing a thread; or go back to list of threads)

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.
Thu Feb 18 2010, 04:02:51, download attachment piecewise_table_test.ld
(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.
Thu Feb 18 2010, 07:12:11, download attachment piecewise_table_testAnalog.ld
(no subject) (by Juan)
Sorry Davide, I see what you mean. Between 882 and 902 the output is 25 as you reach 902 it jumps from 25 to 30. Below 882 it displays 29 and seems to calculate correctly as I descend in the X value.
Thu Feb 18 2010, 07:23:13
error (by simon)
Hi

I whant to test the David R program on atmega8 and atmega32 . The result is an error when compiling the program on LDmicro .

Whi ? Where is the problem ?

Thanks

"Internal error at line 374 file 'avr.cpp' "
Thu Feb 18 2010, 07:36:36, download attachment error.rar
(no subject) (by Juan)
Tried it also. Worked once but that was it. Getting the same error. Tried changing the MCU parameters and reducing the table entries.
Thu Feb 18 2010, 08:39:12
(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.
Fri Feb 19 2010, 23:34:35, download attachment ldmicro.zip
(no subject) (by David R)
HI,
it looks ok I have feed several different value through and the result is correct.

Thanks
David.
Sat Feb 20 2010, 20:15:23
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):