Page 1 of 1

how to get coordinate from mini rx to arduino

Posted: Thu Feb 18, 2021 4:56 pm
by yeni riska
I using dashboard v6.240 and using indoor GPS sterter kit IA-02-3D which consisting of :
4 pcs beacons hw 4.9 as stationary beacons with different frequency
1 mini rx beacon as a hedgehog (mobile beacon)
1 modem.
i have been wiring mini rx to arduino uno using "USB to TTL pl2303 module" to convert d+ d- data to rx tx data
i want to get x, y, z coordinates from mini rx to arduino using serial communication UART. but the result is :
x = 0,00000 y = 0,00000 z = 0,00000 (in freeze condition)
x = 0,00000 y = 0,00000 z = 0,00000
x = 0,00000 y = 0,00000 z = 0,00000
x = 0,00000 y = 0,00000 z = 0,00000
x = 0,00000 y = 0,00000 z = 0,00000 (in unfreeze condition)
x = 0,00000 y = 0,00000 z = 0,00000
x = 0,00000 y = 0,00000 z = 0,00000
x = 0,00000 y = 0,00000 z = 0,00000
how to solve it? is there anything i missed? i have change from uno to mega too but didn't change anything. Thank you in advance

btw, this is my arduino code :

long hedgehog_x, hedgehog_y;// coordinates of hedgehog (X,Y), mm
long hedgehog_h;// height of hedgehog, mm
int hedgehog_pos_updated;// flag of new data from hedgehog received
//#include <SoftwareSerial.h>

#include <AltSoftSerial.h>
AltSoftSerial altSerial (9,8,1);
byte hedgehog_serial_buf[HEDGEHOG_BUF_SIZE];
byte hedgehog_serial_buf_ofs;
const int hedgehog_packet_header[5]= {0xff, 0x47, 0x01, 0x00, 0x10};

typedef union {byte b[2]; unsigned int w;} uni_8x2_16;

//////////Marvelmind hedgehog support initialize////////////////////////
void setup_hedgehog()
Serial.begin(9600); // hedgehog transmits data on 500 kbps
hedgehog_serial_buf_ofs = 0;
hedgehog_pos_updated = 0;

// Marvelmind hedgehog service loop////////////
void loop_hedgehog()
int incoming_byte;
int total_received_in_loop;
int packet_received;

total_received_in_loop = 0;
packet_received = 0;
while(altSerial.available() > 0)
if (hedgehog_serial_buf_ofs>=HEDGEHOG_BUF_SIZE) break;// buffer overflow
if (total_received_in_loop>100) break;// too much data without required header

// check first 5 bytes for constant value
if (hedgehog_serial_buf_ofs<5)
if (incoming_byte != hedgehog_packet_header[hedgehog_serial_buf_ofs])
hedgehog_serial_buf_ofs= 0;// restart bufer fill
hedgehog_serial_buf[hedgehog_serial_buf_ofs++]= incoming_byte;
if (hedgehog_serial_buf_ofs == HEDGEHOG_PACKET_SIZE)
{// received packet with required header
packet_received= 1;
hedgehog_serial_buf_ofs= 0;// restart bufer fill
}//end while

if (packet_received)
hedgehog_set_crc16(&hedgehog_serial_buf[0], HEDGEHOG_PACKET_SIZE);// calculate CRC checksum of packet
if ((hedgehog_serial_buf[HEDGEHOG_PACKET_SIZE] == 0)&&(hedgehog_serial_buf[HEDGEHOG_PACKET_SIZE+1] == 0))
{// checksum success
hedgehog_x= int(hedgehog_serial_buf[9]) + (int(hedgehog_serial_buf[10])<<8);
hedgehog_y= int(hedgehog_serial_buf[11]) + (int(hedgehog_serial_buf[12])<<8);// coordinates of hedgehog (X,Y), cm
hedgehog_h= int(hedgehog_serial_buf[13]) + (int(hedgehog_serial_buf[14])<<8);// height of hedgehog, cm (FW V3.97+)
hedgehog_pos_updated= 1;// flag of new data from hedgehog received
}//void loop_hedgehog

// Calculate CRC-16 of hedgehog packet
void hedgehog_set_crc16(byte *buf, byte size)
{uni_8x2_16 sum;
byte shift_cnt;
byte byte_cnt;


for(byte_cnt=size; byte_cnt>0; byte_cnt--)
sum.w=(unsigned int) ((sum.w/256U)*256U + ((sum.w%256U)^(buf[size-byte_cnt])));

for(shift_cnt=0; shift_cnt<8; shift_cnt++)
if((sum.w&0x1)==1) sum.w=(unsigned int)((sum.w>>1)^0xa001U);
else sum.w>>=1;

buf[size] = sum.b[0];
buf[size+1]= sum.b[1];// little endian
}// hedgehog_set_crc16


void setup()
//pinMode(10, INPUT);
//#define SP2_RX 10
//#define SP2_TX 11
setup_hedgehog();//Marvelmind hedgehog support initialize

void loop()
loop_hedgehog();// Marvelmind hedgehog service loop

if ( hedgehog_pos_updated );
hedgehog_pos_updated=0; // clear new data flag


Serial.print(hedgehog_x*0.01,DEC );
Serial.print(" ");

Serial.print(hedgehog_y*0.01,DEC );
Serial.print(" ");

Serial.print(hedgehog_h*0.01,DEC );
Serial.print(" \n");

Re: how to get coordinate from mini rx to arduino

Posted: Wed Apr 14, 2021 5:59 pm
by smoker77

It seems you are trying not right way for connecting mini-Rx to Arduino.
PL2303 can be used for connecting of UART to USB host, for example you can connect your Arduino's UART to PC through this module USB-TTL.
But from your photo I see you have connected mini-Rx USB to the USB side of the USB-TTL module.
This should not work because mini-Rx acts as USB device, not as host.

Mini-Rx has onboard UART which can be connected directly to Arduino, but the connector is not soldered on the board.
You can purchase this connector with the cable and solder it: