View previous topic :: View next topic |
Author |
Message |
azny
Joined: 25 Aug 2008 Posts: 36 Location: usa
|
Posted: Wed Feb 14, 2018 4:58 am Post subject: |
|
|
exactly right. the way you get around the async problem is to put the measured data into storage, say an array, evry measurement cycle (sure, its alittle more overhead for time) so that when the “a” comes the print statement takes from the array not the ongoing measurement. prety sure the code shows this.
guess what, still doesnt work. now what? |
|
Back to top |
|
|
JC
Joined: 15 Dec 2007 Posts: 585 Location: Cleveland, OH
|
Posted: Thu Feb 15, 2018 1:51 am Post subject: |
|
|
OK, I'm lost.
In the original post you mentioned sending data every 10 mSec.
In the discussion of the external counter chip / circuit you mentioned having a 0.5 Sec gate time.
How often do you really need to send the data up stream?
Is the data being sent to another micro, or to a PC?
Obviously if the data is going to a PC one could (possibly) shift the floating point calc's to the PC and unload the micro.
If the system doesn't work, then you need to back up a step and rebuild the project one step at a time.
Is the serial comm's receiving the "a" reliable?
Are you emptying the buffer after you receive the command?
Test the serial comm's without any of the sensor code.
Next, as I mentioned above, put the data in a packet, with a simple checksum.
e.g.
< A A A B B B C C C Chksum
Where "<" is a Start of Packet character.
It could be anything, but it allows the upstream parser to easily identify the start of a new packet.
AAA = the 3 Bytes of Sensor A data.
BBB
CCC
CheckSum is simply the 8-bit sum of AAABBBCCC, ignoring any carryout.
The data receiver finds a Start of Packet character, then it reads in 9 bytes of data, and then it reads in the Checksum.
It also calculates the CheckSum to make sure that it:
Correctly identified the Start of a Packet, and not a data byte that matched the SOP character
Correctly received the data elements.
If the Received data addition Checksum matches the transmitted Checksum then life is good.
Reassemble the data bytes into 24 bit data and move on with your processing.
If they don't match, then trash the data and go watch for the next SOP character.
Next, DON'T use your sensor code.
Just stuff known, dummy data into the data packets to transmit when the "a" is received.
The dummy data can be printable characters, which makes it easy to look for data integrity/error on a PC terminal program.
a
<123456789_
a
<123456789_
a
<123456789_
etc.
You can do that all day and make sure the serial comm's, and the micro receiving the command and acting on it all work correctly.
Next, add ONE sensor.
Stuff that sensors data in all three sensor data slots.
Make sure that works.
Then add the additional sensors.
As always, try making your three stack values larger, also.
Make sure you aren't doing the floating point calc's inside an ISR without using the special flag to save the additional registers.
MWS already checked and said you are good there, but as you re-write code, keep it in mind.
JC
Edit: Typo |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|