You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm sending joystick values via Nano connected to HC12, to a ProMicro Receiver also attached (obviously) to an HC12. I was running both at 9600 baud with a delay (in TX) of 250 mS. I don't like the delay but will deal with that after I get better results. As I go down in delay, the frequency of Stale Packets increases. At 250 mS, I get a couple a minute. I increased the baud of the system (HC12 and serials) to 19200 and get maybe 1 stale packet every 2 minutes.
I had other Serial sketches that did all kinds of manipulation to improve throughput but they did not work and your library makes everything so much simpler, so its definitely the way to go.
But...my problem is the receiver is for a robot and when it receives bad data (it was triggering on < begin data markers before) the motor driver is triggered and the robot begins to move forward. So...at this point if I'm going to get packet errors, I must prevent that bad data from getting passed to the motor driver (a simple H bridge using L9110). How can I do this effectively? I'm not even at a point of calling myself "intermediate programmer" (I'm real old school Assembly programmer), so need some guidance. This is the current (test) setup, basically your example receive code:
`#include "SerialTransfer.h"
SerialTransfer myTransfer;
int xAxis;
int yAxis;
struct STRUCT {
int x;
int y;
} testStruct;
//char arr[6];//Count # of characters inc spaces in transmit char arr
void loop() {
if (myTransfer.available()) {
// use this variable to keep track of how many bytes we've processed from the receive buffer
uint16_t recSize = 0;
And my TX code:
`#include "SerialTransfer.h"
#include <SoftwareSerial.h>
//SoftwareSerial HC12(9, 10);
SerialTransfer myTransfer;
int xAxis;
int yAxis;
struct STRUCT {
int x;
int y;
} testStruct;
//char arr[] = "hello"; //count # of characters, put in TX char arr[29]
A stale packet occurs when the beginning of a packet is received, but the rest of the packet isn't received before a timeout occurs. In your case (streaming data constantly), it suggests there are Serial input (or output) buffer overflows. Cranking BOTH the USB and HC-12 bauds as high as possible will help mitigate this. You might even want to look at increasing the serial buffer sizes (I don't know how to do that for the boards you are using). I hope it helps
I'm sending joystick values via Nano connected to HC12, to a ProMicro Receiver also attached (obviously) to an HC12. I was running both at 9600 baud with a delay (in TX) of 250 mS. I don't like the delay but will deal with that after I get better results. As I go down in delay, the frequency of Stale Packets increases. At 250 mS, I get a couple a minute. I increased the baud of the system (HC12 and serials) to 19200 and get maybe 1 stale packet every 2 minutes.
I had other Serial sketches that did all kinds of manipulation to improve throughput but they did not work and your library makes everything so much simpler, so its definitely the way to go.
But...my problem is the receiver is for a robot and when it receives bad data (it was triggering on < begin data markers before) the motor driver is triggered and the robot begins to move forward. So...at this point if I'm going to get packet errors, I must prevent that bad data from getting passed to the motor driver (a simple H bridge using L9110). How can I do this effectively? I'm not even at a point of calling myself "intermediate programmer" (I'm real old school Assembly programmer), so need some guidance. This is the current (test) setup, basically your example receive code:
`#include "SerialTransfer.h"
SerialTransfer myTransfer;
int xAxis;
int yAxis;
struct STRUCT {
int x;
int y;
} testStruct;
//char arr[6];//Count # of characters inc spaces in transmit char arr
void setup() {
Serial.begin(19200);
Serial1.begin(19200);
myTransfer.begin(Serial1);
}
void loop() {
if (myTransfer.available()) {
// use this variable to keep track of how many bytes we've processed from the receive buffer
uint16_t recSize = 0;
}
}`
And my TX code:
`#include "SerialTransfer.h"
#include <SoftwareSerial.h>
//SoftwareSerial HC12(9, 10);
SerialTransfer myTransfer;
int xAxis;
int yAxis;
struct STRUCT {
int x;
int y;
} testStruct;
//char arr[] = "hello"; //count # of characters, put in TX char arr[29]
void setup() {
Serial.begin(19200);
//HC12.begin(9600);
myTransfer.begin(Serial);
}
void loop() {
testStruct.x = analogRead(A2);
testStruct.y = analogRead(A3);
// use this variable to keep track of how many bytes we're stuffing in the transmit buffer
uint16_t sendSize = 0;
sendSize = myTransfer.txObj(testStruct, sendSize);// Stuff buffer with struct
// sendSize = myTransfer.txObj(arr, sendSize); // Stuff buffer with array
myTransfer.sendData(sendSize); // Send buffer
delay(250);//def was 500
}
`
The Nano is not using software serial (slower, more errors) so I'm using HW Serial. The ProMicro has a separate Serial1.
The text was updated successfully, but these errors were encountered: