Serial commands from computer through arduino to another device

Hi everyone,

I currently have a computer controlled stimulator (usb driven). So when I send specific bytes it stimulates with the intensity and pulse width contained in the data sent. Basically I want to monitor the usb connection with the arduino uno connected in between the computer and device. Then if a certain byte is sent I want change a digital pin on the arduino from low to high. From what I have read it seems the tx/rx pins can be used to transmit data but not sure they are directly connected to the usb connector.

Hope this makes sense.

Thanks

If you are using the hardware serial (pins 0, 1) to communicate with the PC you can't also use it the connect with another device. Use Software Serial library (comes with the IDE) on 2 other pins to connect with the other device. Monitor the software serial port for the trigger byte.

Thanks. I am not using the hardware serial (pin 0,1) to communicate with the PC (at least I don't think I am). I am using the USB connector. Not sure if this makes a difference.

If I understand you correctly though, you are suggesting to send the data to the arduino then use a software serial to resend the data to the device.

Yes, that's it. You don't say which Arduino. i only know the Uno (mega328). If you have a Uno, and are connected via USB then you are using pins 0 and 1 which are the hardware serial port pins. So set up a software serial port, on 2 different pins, and connect that to the other device. You can then send and receive from the other device, have the Arduino act on received data and relay to the PC.

If you are using the hardware serial (pins 0, 1) to communicate with the PC you can't also use it the connect with another device.

Bad information that is becoming a forum urban legend, probably because many don't understand the TTL operations. The arduino can send tx to a large number of rx, and the arduino can receive rx from a large numbet of tx if each tx has a properly aligned diode in the tx line.

zoomkat:

If you are using the hardware serial (pins 0, 1) to communicate with the PC you can't also use it the connect with another device.

Bad information that is becoming a forum urban legend, probably because many don't understand the TTL operations. The arduino can send tx to a large number of rx, and the arduino can receive rx from a large numbet of tx if each tx has a properly aligned diode in the tx line.

But Serial protocol was not intended for doing a multiple nodes network, was it? CANBUS or MODBUS, or I2C are more suitable for that task (I'm talking about the protocol, not the physical layer).

To the OP, If you "other device" supports I2C and it is close to your arduino, I would recommend using RS232 between Arduino and PC, and I2C between your other device and Arduino.

Bad information that is becoming a forum urban legend, probably because many don't understand the TTL operations. The arduino can send tx to a large number of rx, and the arduino can receive rx from a large numbet of tx if each tx has a properly aligned diode in the tx line.

Zoomkat. My bad then. This is the first that I have heard of this and would like to know more about the technique. Would one also need a protocol to identify the sender and/ or receiver?

Best solution for using multiple serial devices and the USB is to use a mega board as it has four hardware serial channels with channel 0 wired to the USB.

groundfungus:

Bad information that is becoming a forum urban legend, probably because many don’t understand the TTL operations. The arduino can send tx to a large number of rx, and the arduino can receive rx from a large numbet of tx if each tx has a properly aligned diode in the tx line.

Zoomkat. My bad then. This is the first that I have heard of this and would like to know more about the technique. Would one also need a protocol to identify the sender and/ or receiver?

The key to the TTL serial tx/rx is that both the tx and rx pins are normally held high at 5v when no transmission is occurring. The rx pin is internally "lightly’ held high at 5v so that it is not susceptible to line noise. The tx pin is normally at 5v, but goes to ground when it sends a bit. This also pulls the connected rx pin to ground, which tells the rx it is receiving a bit. The tx goes back to 5v at the completion of the bit send. This causes/allows the rx pin to go back to 5v indicating the end of the bit send. So one tx pin can pull a number of connected rx pins low. For a number of tx pins to be connected to a single rx pin, a diode is needed on each tx pin connected to the rx pin. With out the diodes, all the tx pins would be holding the single rx pin high, preventing a single tx pin being able to pull the rx pin low. The diodes (band end connected to the tx pin) prevent the tx pins from feeding 5v to the rx pin keeping it high at 5v. Each tx pin can still pull the rx pin low. With the arduino USB serial connection, a diode can’t be put on the internal tx pin, but in my test the USB tx pin did not prevent another external tx pin from pulling the arduino rx pin low. YMMY. You will still need to add identity features to the slave arduino code.