03-26-2015, 05:52 PM
Reading Digital caliper with Arduino
|
03-26-2015, 05:58 PM
Much easier. I see 0.333"
03-26-2015, 06:14 PM
Try disconnecting the scale from the data line and then tie it high and see what the app thinks it is reading. Then tie it low and it had better think all the bits are the opposite.
If it doesn't change then ...
03-26-2015, 09:18 PM
I wasn't bothering with us/metric. I just figured all the remaining bits would be 0s. Using the same data that I read earlier when I came up with .333, yes it is 6.66 mm.
03-27-2015, 06:46 AM
(03-26-2015, 08:40 PM)arvidj Wrote: Try disconnecting the scale from the data line and then tie it high and see what the app thinks it is reading. Then tie it low and it had better think all the bits are the opposite. What I did before I went to bed last night was to use the diagnostic output pin and in the ISR right after reading the data bit in and storing it in the shift register I output that data bit to the diagnostic pin and the pin followed the data on the input pin so I know it's reading the data bit properly. It has to be something in the way we are storing the bits or displaying the bits. When I get home from work today, I'm going to try putting the serial.print inside the ISR and see if the data displays properly. I know it's advised not to do that but for a test it'll add one more bit of information to help solve this. Ed
I don't think you can put the print statement inside the interrupt because it uses inter ups to function. I'll look at the code tomorrow morning and fix it. I actually think I know what is wrong.
03-27-2015, 07:38 PM
Good because I'm running out of ideas. I did have a bit, no pun intended, of success by having the ISR just set a flag when a bit was available and then in the main routine I processed the bits. It worked, to a point anyway. I have to go into work tomorrow morning but I'll be able to access the forum from work.
Ed
First thing to try ... and yes, this is one of those "DUH, where did that come from" moments.
In the main processing loop there is are these lines ... Code: ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // Needs to be marked as atomic so the interrupt does not mess with it while we get a local copy of it and I think we need to change it to ... Code: ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // Needs to be marked as atomic so the interrupt does not mess with it while we get a local copy of it I'm not exactly sure where the '= 0' came from but it is certainly wrong; I also changed how the value of the data line is captured in the interrupt. Here is the code for the new, improved version [don't forget to remove the 'include' at the top of the file. Note the new define ... DATA_STATE_INDICATING_A_ONE ... which will allow us to easily set if a HIGH or a LOW on the data line means ONE. Code: // Do not remove the include below Let me know if this is progress or ..., Arvid
03-28-2015, 08:39 AM
Arvid,
All that shows up in the serial monitor is "Ready:". No data. One thing I haven't mentioned yet that I noticed a couple of days ago is that you're shifting the bits left which will put the least significant bit into the most significant bit position. Ed |
« Next Oldest | Next Newest »
|
Users browsing this thread: 7 Guest(s)