Arduino Communication

  • @HoughA

    I think the issue might be with using D3 and D4 as Tx and Rx pins for Serial1 in the the teensy 3.2. It looks like they are the Tx, Rx pins for the CAN bus not a UART .... You could use SoftwareSerial on these pins. The other option would be to move to something like I2C or SPI.

  • @Will-Dickson Thank You!!! that did the trick. i have them both communicating. However, the rodeostat only starts to read the arduino message after i press return in the serial monitor, is there some kind of Ready or begin message its expecting?

  • @HoughA Great. I'm glad to hear you got it working.

    Another option, if you really want a hardware serial port, is the other header P14. The pins D26 and D31 on that header can be used at the Rx and Tx pins for Serial2. See the serial docs for the various teensys here

    Regarding pressing return in the serial monitor. The potentiostat's MessageReceiver, implemented in ps_message_receiver.h and ps_message_receiver.cp, only decides that a new message has arrived after receiving the '\n' character. The Arduino Serial Monitor sends a '\n' when you press return ... so could be that. Maybe adding a '\n' to the end of all messages sent to the teensy would help.

  • @Will-Dickson Thats actually what i ended up doing to get it to work!

    in regards to the serial problem, i tried adding a Serial2.print("\n"); as well as Serial2.println();. Neither one is getting it to work. any other ideas?

  • Even when i have the usb serial.begin for the rodeostat nothing happens, but i can still open serial monitor and press return or send any kind of code and the rodeo stat begins reading the arduino.

  • @Will-Dickson Another question is what is the highest frequency that the Sinusoidal voltammetry can operate at?

  • @HoughA

    There are a couple things that come into this.

    First, the output voltages are set at discrete time points via the testTimer which run by default at 5kHz. To make a reasonable approximation of a sine wave you will probably want enough points - maybe 50 or so. So you could probably output reasonable approximations of sinusoids voltages up to frequencies of about 100Hz.

    Second, the data is not sent back to the PC (or other device connected via UART) at every update of the testTimer. Rather it is sent at a lower sub-sampled rate set by the sample rate (or actually sample period in the firmware). The maximum value for the sample frequency is 1000Hz. You will need sufficient number of sample points at which to measure the current you get in response to the sine wave output. So maybe 20 or 30 or 50 ... the exact number depends on your needs. Lets say that 20 is sufficient. Then this further reduces the maximum sinusoid frequency to 50Hz (1000/20).

    Third you will need to take into account the bandwidth of the current measurement range you are using e.g. +/- 1uA, +/-10uA, +/-100uA, +/-1000uA. Each of these channels will lowpass filter the measure signal to some extent based on the resistor capacitor combination used in the feedback network of the transimpedance amplifier. The more sensitive channels will have lower cutoff frequencies. The +/-1000uA and +/-100uA channels have pretty high cut off frequencies such that it won't be an issue. However, the +/-10 uA and +/- 1uA ranges have cutoff frequencies of approximately 47Hz and 4.7Hz respectively. So if you are using these channels this will limit the bandwidth of your measurements somewhat or at least you should be aware of the possible attenuation of the measurements at higher frequencies.

  • @HoughA It will be awesome if you could post your arduino/teensy codes and some kind of schematic for the rest of us that are still fighting with this issue!

    Thank you!

  • Ey guys, after working on this along the afternoon I have solved the issues in our case.

    For the future generations that want to integrate Rodeostat in their Arduino based platforms:

    1. The Hardware: As Will has said before, you will need to connect the Arduino to the teensy in one of the possible ways (SoftwareSerial, I2C, SPI, Hardware Serial (like Serial2...)). In our case we have connected it by Hardware Serial, with Serial2 in the pins 26 of the P14 connector (see the schematic that Will attached before, remeber that the arrow in the pcb indicate the first pin of the header) to a TX pin in the Arduino (in our case the TX2 pin in Arduino Mega) and the 31 (also in the P14 connector) to the RX pin in the Arduino. For powering the rodeostat you will also need to connect the ground from teensy (like the one in the P13 or P14 connector) to the ground in Arduino, and 5V of Arduino to the pin 5V in the teensy PCB. This last pin is located under the P13 connector, there are four pins and the sign "5V" are near the internal pin of the PCB but TAKE CARE the 5V pin is the one in front of this, the one near the border of the PCB. That letters lead to an error.

    2. The Arduino software. You could use the one that @HoughA have post before, measuring the voltage between the "DAC BIP" hole in the pcb and a hole connected to ground. The voltage should change between 1 and 0 every second (if you polymeter don´t change this fast, just change the code and set a delay of 5 secs).

    3. Teensy software. First of all, you will need to add this lines to the setup function in the Arduino file (these lines are specific if you are using Serial2 communication, substitutes them for your own system):


    You will need also to change the functions that receive the messages from the normal usb serial port, and set them to receive by Serial2 port instead. For doing this just open the files ps_message_receiver.cpp and ps_message_sender.cpp (this one if you want to also receive the response in your arduino instead of your PC) from the potentiostat library and change every line in which you see "Serial." to "Serial2."

    If you made only this changes you will have the problem that @HoughA have faced before; Your Arduino and your Teensy only communicates after you send something over the normal Serial port with a PC. This is because we don't have changed the Serial Event handler in the Arduino code. This handler triggers on with a new Serial communication and updates the message data.

    This handler function is located at the bottom of your .ino file. Is called SerialEvent and you will need to change it to SerialEvent2 (To handle Serial2 events instead of Serial events).

    Sorry for my poor English. Hope this comment has given you a hand.

    Hugs from Madrid,


Log in to reply