Other Parts Discussed in Thread: PGA460, , ENERGIA
Hi ,
We have been trying to interface PGA460PSM-EVM with Arduino MEGA . We are planning to use 6 PGA460s and recieved all 6 of them. We tried the following procedures but not able to communicate with the pga460 module.
Our connections as follows
Arduino MEGA <===> PGA460PSM-EVM
TX1<===> RX ( A voltage divider which converts 5V logic to 3.3V logic
RX1 <===> TX (direct connection)
PWR <===>12V 1A supply
GND PGA460 <===>GND MEGA <===> POWER GND (common ground for all)
SCK pin is grounded with 10k resistor
The TEST pin is floating assuming the PGA460 works in 3.3V logic state .
At first
1. we tried using the ported energia libraries for arduino mega provided by Mr Akeem Whitehead in this link unfortunately we got
ERROR - did not recieve measurement results...
2. We then tried out this following code
//note: minimum requirement example used to send a burst/listen command to PGA460 //cmd 0 - p1 burst listen byte buf0[4] = {0x55, 0x00, 0x01, 0xFE}; //cmd 1 - p2 burst listen byte buf1[4] = {0x55, 0x01, 0x01, 0xFD}; //cmd 5 - ultrasonic measurement (assume UART_ADDR=0) byte buf5[4] = {0x55, 0x05, 0xFA}; //change //cmd 10 - register write decple to time of 4.096ms byte buf10[5] = {0x55, 0x0A, 0x26, 0x00, 0xCF}; //cmd 17 - broadcast p1 burst listen byte buf17[4] = {0x55, 0x11, 0x01, 0xED}; //cmd 19 - broadcast p1 listen only byte buf19[4] = {0x55, 0x13, 0x01, 0xEB}; //cmd 25 - broadcast bulk threshold write byte buf25[35] = {0x55, 0x19, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x84, 0x21, 0x08, 0x42, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x84, 0x21, 0x08, 0x42, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x7C}; unsigned char data; const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin int buttonState = 0; // variable for reading the pushbutton status void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); delay(1000); // put your setup code here, to run once: Serial.begin(19200); Serial1.begin(19200,SERIAL_8N2); // initialize PGA460 UART serial channel SERIAL_8N2 delay(1000); //assume UART_ADDR=0 //bulk threshold write mid-code values to clear THR_CRC_ERR Serial1.write(buf25, sizeof(buf25)); delay(100); // set UART_ADDR=0's time decouple to 4.096ms Serial1.write(buf10, sizeof(buf10)); delay(100); } void loop() { // put your main code here, to run repeatedly: // check if the pushbutton is pressed. while (digitalRead(buttonPin) == LOW){} // broadcast p1 burst+listen (non-dependent on UART_ADDR) Serial1.write(buf17, sizeof(buf17)); // delay by 100ms delay(100); //[TODO] print ultrasonic measurement results on terminal // read back ultrasonic meas results from UART_ADDR=0 Serial1.write(buf5, sizeof(buf5));//Serial1 data = Serial1.read(); Serial.println(data); // toggle red LED digitalWrite(ledPin, !(digitalRead(ledPin))); // turn the LED on (HIGH is the voltage level) // repeat loop every second delay (1000); }
But we had 255 as output in our serial monitor ( even if the wires are removed ) , we think those are garbage values .
3. We just wanted to confirm if there is a communication between PGA460 and Arduino so we used the following example code .
unsigned char WriteByteArray[4] = { 0x55, 0x09, 0x1B, 0xDB }; unsigned char ReadByte1; unsigned char ReadByte2; unsigned char ReadByte3; void setup() { Serial.begin(115200); Serial1.begin(115200, SERIAL_8N2); } void loop() { Serial1.write(WriteByteArray,sizeof(WriteByteArray)); Serial1.flush(); ReadByte1 = Serial1.read(); ReadByte2 = Serial1.read(); ReadByte3 = Serial1.read(); Serial.println("ReadByte1 = "); Serial.println(ReadByte1); Serial.println("ReadByte2 = "); Serial.println(ReadByte2); Serial.println("ReadByte3 = "); Serial.println(ReadByte3); delay(1000); }
Again we got 255 in ReadBytes 1 , 2 and 3 . Can you please guide us in establishing a communication? Akeem Whitehead1