gcc -o uart_rpi3_loopback uart_rpi3_loopback.c -lwiringPi
- yamaguchi-am
- amuthelet
- spiralray
- YuuichiAkagaw
- libkondo
- Kondo_with_ros_comples
- Kondo_with_ros_simple
With Pi:
Tx Pin:
oscilloscope = 800
microseconds for 115200
BaudPerSec and delay = 3.2
milliseconds
With Arduino:
Tx Pin:
oscilloscope = 80
microseconds for 115200
BaudPerSec and delay = 0.304
milliseconds
oscilloscope = 20.00
microseconds for 625000
BaudPerSec and delay = 0.064
milliseconds
oscilloscope = 8.00
microseconds for 1250000
BaudPerSec and delay = 0.049
milliseconds
Rx Pin:
- Why the fuck its not working with two while loop
- How to get rid of garbage value?
Make sure UART is configured in RPI3, use this as reference.
- PiPinOut
- wiringPi_Pinout
- WiringPi
- Electronics_wing
- Odroid
- SerialTest
- Minicom
- [GitHub Discussion] (ARMmbed/mbed-os#1849, ARMmbed/mbed-os#1801)
- [open function] (http://pubs.opengroup.org/onlinepubs/7908799/xsh/open.html)
- Control modes in UART used in WiringPi library
- Reference for setting input & output baud rate
- [Blocking POSIX (tcdrain)](https://linux.die.net/man/3/tcdrain, https://www.linuxquestions.org/questions/programming-9/serial-port-write-wait-for-transmission-complete-with-the-function-tcdrain-4175502564/)
- posix serial
- Use minicom to test if Tx --> Rx communication is established or not.
Install minicom: sudo apt-get install minicom
If java packages are missing when installing minicom, install them using the following commands:
sudo apt-get purge openjdk-8-jre-headless
sudo apt-get install openjdk-8-jre-headless
sudo apt-get install openjdk-8-jre
Test if a communication line is working by using:
sudo minicom -D /dev/ttySo
ls -l /dev | grep
Compile: gcc -o test test.c -lwiringPi Run: ./test
On running ics.c, the enable pin is high briefly but turns low immediately, not waiting for the data transmission to complete. Need to clear the non blocking io flag.
Created two new files ics_new.c and stoch_kondo.c. stoch_kondo.c is the final library that aims to replace wiringPi completely. I am replacing all the functions in ics_new.c for the ease of testing. Once verified to work properly, the functions are placed in stoch_kondo.c
Tried replacing the wiringPi library in the ics.c with all posix commands. Too many errors to handle when using this approach. In the end only the open and write functions were incorporated in ics.c
Increasing the delay in the code to match enable signal with tx line worked. However, it is not dynamic to adapt to transfer any number of bits Since the number of bits transmitted in all commands (setPos,getPos,set Curlim etc.), this approach is assumed to work for our purpose The delay time to be used in the code is measured by plotting the channels from an Arduino whose code is perfect and has no errors.
IMPORTANT: Added tcdrain(fd) and tcflush(fd) to ics.c and each time the tx pin is high, enable pin goes high. However, enable pin becomes low even during data transmission (i.e, when 0 is transmitted).
-
The use of POSIX function tcflush() is to flush all data there in the object referred by fd, but not transmitted. Usage:
int tcflush(int fildes, int queue_selector);
-
Types of queue_selectors are as follows:
a) TCIFLUSH, it shall flush data received but not read. b) TCOFLUSH, it shall flush data written but not transmitted c) TCIOFLUSH, it shall flush both data received but not read and data written but not transmitted.
IBM support page on waiting until o/p is transmitted
Summary:
tcdrain() waits till all output sent to fd is actually sent to through the port mentioned by fd If successful, tcdrain() will return 0. Else, it returns -1. There is an example for usage availble.
QNX documentation on tcdrain x Similar to previous link. Smaller example code for the usage.
Clean up of code is complete and the expected results on oscilloscope is obtained. Refer top of this document for oscilloscope settings.
calculate the time taken for sending one byte in TX in UART in RPI3 and Arduino.
To do:
- Write a library for set functions (setPos, setCurlim, setSpd etc.)
- Plot the output of Rx pin using Arduino and try to replicate the same using Rpi3
- Figure out how to use the synchronize function in the code
- Mimic wave form of Rx pin obtained using Arduino using the Rpi3
- Complete kondo_stoch.h library by adding all the get functions (getPos, getSpd etc.)
- Make a similar alias using Python and test
- Optimisation and threading