Go Down

Topic: Attempting to Extract Data from a Serial Handheld to Arduino (Read 322 times) previous topic - next topic

chillynelson

Hello,

I work as an intern at a company and I have little experience with C. I read about slave & bus communication, and attempted to run some code for this project but made little progress.

I have a serial handheld used to collect data and I am attempting to communicate the handheld to an Arduino Uno Infiduino R3. I am using an SainSmart USB Hot shield to connect the serial handheld to the Arduino.

Here is the code I have so far,

Code: [Select]

#include <Wire.h>
#include <SPI.h> // For Serial Peripheral Interface - For T/C




unsigned long O2 = 0x03;
unsigned long CO = 0x04;
unsigned long No = 0x05;
unsigned long NO2 = 0x06;
unsigned long SO2 = 0x07;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Serial.println (O2, HEX);
Serial.println (CO, HEX);
Serial.println (No, HEX);
Serial.println (NO2, HEX);
Serial.println (SO2, HEX);
}

void loop() {
  // put your main code here, to run repeatedly:

}

--


I need help with establishing communication between the serial handheld and the Arduino. Any help would be greatly appreciated and I thank you in advance.

pylon

Quote
I need help with establishing communication between the serial handheld and the Arduino.
Simply impossible as you didn't give us the slightest information about that device. It's rather strange that you call it a "serial" handheld but it seems to connect to the Arduino by USB. Your code does absolutely nothing other than sending some non-printable characters back to the controlling PC.

chillynelson

We have an emission analyzer with the attached USB protocol. It should act like a serial communication.

 

We know we need to set the baud rate to a fixed rate and then start the serial communication to the analyzer. We know it should return 8 bits and 1 start/stop bit. Then we need to send the "Command 2" ($0802EE,CR) or "Command 5" ($0A05HH) to the analyzer to receive return values. And then decode the return values. We don't need all of the retuned values if we do command 2, just a few select ones (note the ones received are the ones on pdf page 6). We are really only looking for O2, CO, NOx and internal flow.

 

We should only need to read the values but say every second or so for what we want to do.

 

We have used this same protocol in DASYLAB (similar to Labview) with assistance from Dasylab and received the values by setting the baud rate, sending the command 2, and decoding the return values. But with Arduino it's a little different.

pylon

Quote
We have used this same protocol in DASYLAB (similar to Labview) with assistance from Dasylab and received the values by setting the baud rate, sending the command 2, and decoding the return values. But with Arduino it's a little different.
The protocol description as well as the fact that it worked with a PC software let me assume that device is not a USB host device but a USB slave device. You already wrote that you have a USB host shield but you don't access it in your sketch. It depends on the USB2serial chip used on that device if it is already supported by the USB host shield library. If that chips isn't already supported you may have to develop a driver for it. Most probably it will be easier to forget the Arduino and change to a Raspberry Pi based setup.

jremington

If you want help communicating with your device, identify it accurately, and post a link to the data sheet or manufacturer's product page for the device.

So far, your posts haven't communicated any useful information.

Go Up