If you can, please show us exactly what you got, no interpretation by you.
in the code of post 16 you are using Serial to receive the RS232 data and also display the results???
how have you connected the radio to the arduino? post a schematic showing the wiring?
I've only put a jumper wire on the radio tx-pin in the RS232 connection to the serial RX pin on the arduino Uno wich I belive is pin 0 among the digital pins. I made a "split" with a female and one male RS232 connector. Therefore had I the singular pin for TX and RX for the radio. The code is to see if I reconized any data that came from the radio but I didn't, because the hexadecimal was what I belive a long constant. Now I understand why reading the radio TX-pin wasn't a success, I didn't have the right module to preform any serial communication with RS232 and the arduino uno.
Hopefully, you didn't leave it connected too long, as the RS232 signal voltage levels are well outside of the Arduino's tolerance. Time will tell.
Thank you!
- I do not but now I've ordered one.
- I did only use the RX pin with the help of a jumper wire so not a fully stacked "pin-list"
- I DO know the amount of bits, parity and stop my radio uses. How do I change the setings for the arduino UNO? The radio uses no parity bits, one start bit and two stop bits.
I've now bought a module and it's arrived. I connected everything with the module using this code:
int incomingByte = 8; // for incoming serial data
void setup() {
// put your setup code here, to run once:
Serial.begin(4800, SERIAL_8N2);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
This time the serial monitor is completely empty. I put incomingByte to pin 8 because i didn't want the arduino and computer communication. The radio and computer communicate while I try to snap or "drain" some information with a juperwire leading to the RS232-ttl module connected to RX.
The module has ground, 5v and RX goes to pin 8 on the Arduino.
If I burned the serial input with the direct connection on rs232 signal, could I test this in some way?
Sorry, but you wrote a complete non-sense. The variable incomingByte has nothing to do with pins.
And what do you expected to see in the Serial in that case? The Serial always uses the pins 0 & 1 for connections.
Sorry, but It looks like you don't have even basic knowledge for this project.
you are not reading from pin 8 but from the USB Serial
see code in post 10 of how to read from pin 8 using AltSoftSerial
For context I used the example code found on the arduino website explaining Serial.read()
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
I find it difficult to understand the explanations found under the Serial page
What do you mean by this ?
The incomingByte variable is the byte, that you received via UART.
It is a data, and not the pin or something else.
Serial page does contains nothing about the incomingByte. It is not a predefined name or system constant, it just a variable in your code.
I could recommend you to read the Serial Input Basics Tutorial before you going further.
in addition to basic Serial IO with keyboard and display you require an additional serial port to communicate with your radio
for a discussion of the alternatives have a read of arduino-serial-a-look-at-the-different-serial-libraries
Now I've read all the different links that you suggested and I've also done the echo test with AltSoftSerial described in post 10.
I understand now that pin 1 and 0 on the arduino is used for the serial communication to the computer. Therefore need I a AltSoftSerial to recieve serial data through pin 8 and leave the original serial port for arduino - computer communication.
#include <AltSoftSerial.h>
AltSoftSerial altser;
const int mybaud = 4800;
void setup() {
Serial.begin(4800, SERIAL_8N2);
while (!Serial)
; // wait for Arduino Serial Monitor
altser.begin(mybaud); // to AltSoftSerial RX
Serial.println("\n\nAltSoftSerial transmit/ Receive Test");
Serial.println("on a UNO connect pins 8 and 9 for a loopback test");
Serial.println("using RS232 module connect pins 2 and 3 for a loopback test");
Serial.println("characters entered on serial monitor keyboard are echoed back via serial to the display");
}
void loop() {
if (altser.available() > 0) {
Serial.println(altser.read(), HEX);
}
}
By using this code that is a modified one from post 10 I mananged to recieve what the computer is sending to the radio and visa versa. The computer sends in a 5 byte command structure where the 4 first bytes is arguments and byte 5 is a instruction OPCODE that request different sections of the radio's internal memory.
The computer sends:
0
0
0
3
10
0
0
0
0
FA
Looping where the first 5 bytes request data about the two recievers I have in my radio. The info is for example band selection, operating frequency and clarifier offset. The returning info from the radio is 32 bytes (16 bytes per VFO).
Here is the data displayed from the code above listening from the radio. This is the first 16-bytes that describes VFO-A data.
00:42:15.075 -> 11
00:42:15.075 -> 1
00:42:15.108 -> 5B
00:42:15.108 -> E6
00:42:15.108 -> 8C
00:42:15.108 -> 0
00:42:15.108 -> 0
00:42:15.141 -> 2
00:42:15.141 -> 31
00:42:15.141 -> 2
00:42:15.141 -> 11
00:42:15.174 -> 31
00:42:15.174 -> 11
00:42:15.174 -> 11
00:42:15.174 -> 11
00:42:15.207 -> 0
With these 16 bytes I can manually translate that the radios VFO-A is inbetween 14.0 - 14.5 MHz just on the first byte. Then the 4 bytes after that says that the radio is on frequency 14.250 in CW mode.
The second 5 bytes that the computer sends request to read flags. 6 different "flags" that indicate what kind of functions that's active on the radio. This returns a 5 byte info where the first 3 bytes is flag bytes and the last 2 is ID bytes that indicate that the radio is a YAESU FT-1000 mp.
00:42:15.002 -> 8
00:42:15.002 -> 20
00:42:15.002 -> 0
00:42:15.002 -> 3
00:42:15.043 -> 93
I have some trouble decoding this manually because there is 6 different flags with 8 total functions each. This uses bit offset to indicate on or off for all 48 functions on only 3 bytes? Thats a bit outside of what I understand at the moment.
If you would like I've made a cut out of the manual with just the 6 pages you need from the manual to understand what the radio is giving answers on and what the returning bytes mean.
ft1000mp_manual_cat_info.pdf (967.5 KB)
What I've understand is that I would need some way to know when the arduino should listen and stop listen to recieve these 32 bytes of data. Then knowing I only have these 32 bytes be able to manage the data and analyze it. To be able to recieve both radio and computer sides I need two RS232-TTL level shifters? Or could I in anyway break out only the 32 bytes in the waterfall of data coming from the radio? The problem is also that the radio does not use start or end markers for its communication, it just keep sending.
If you're using Serial Monitor, the data format is 8N1. So you need to change that. There is also no reason to have the communication with the PC at such a low speed. So I would start with
Serial.begin(115200);
and have the matching baud rate in Serial Monitor.
The serial monitor speed doesn't change anything. The communication between radio and computer is 4800 baud so going faster than that have no purpose unfortunately.
I'm not going to have the computer hooked up to the arduino later on when the project is finished. I want to analyze the data now and visualize how it's looking to later on depending on what info the radio sends, display on a small screen and also set one specific pin to HIGH.
But, it does! You may wish to send more info to the computer when debugging, and the last thing you want is the Serial Monitor bogging down, interfering with your processing of input from the other Serial source.
no, it is a baudrate between radio and arduino
But the radio and Arduino is not communicating. Iâm listening on an already made communication between another program on my computer and the radio and that communication is 4800 baud. Iâm only using rx on the RS232-ttl level shifter module because all I want to do with the Arduino is to listen.
Now the project is finished. I've used for example readBytes() to just recieve the 32 bytes I want. Here you can see the code, unfortunately the comments are in Swedish.
#include <LiquidCrystal.h>
#include <AltSoftSerial.h>
// Inkluderar nödvÀndiga bibliotek
byte data[32];
// Skapa en array pÄ 32 bytes att lagra data som ska processas
AltSoftSerial altser;
const int mybaud = 4800;
// Starta alternativ seriell motagning
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// LCD display pinout
int ledPin = 9;
void setup() {
lcd.begin(16, 2);
lcd.print("VFO-A:");
lcd.setCursor(0, 1);
lcd.print("VFO-B:");
// Initiera LCD
altser.begin(mybaud);
Serial.begin(4800);
// Starta seriella kommunikationer
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
if (altser.available() > 0) {
int rc = altser.read();
// LĂ€s av inkommande bytes, spara som integer
if (rc == 147){
// Kolla om id-byte HEX 93 skickas, 147 decimalt uttryckt
altser.readBytes(data, 32);
// Spara 32 bytes i array
}
if (data[0] == 4){
lcd.setCursor(6, 0);
lcd.print("160m ");
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
if (data[0] == 8){
lcd.setCursor(6, 0);
lcd.print("80m ");
}
if (data[0] == 11){
lcd.setCursor(6, 0);
lcd.print("40m");
}
if (data[0] == 14){
lcd.setCursor(6, 0);
lcd.print("30m ");
}
if (data[0] == 17){
lcd.setCursor(6, 0);
lcd.print("20m ");
}
if (data[0] == 20){
lcd.setCursor(6, 0);
lcd.print("17m ");
}
if (data[0] == 22){
lcd.setCursor(6, 0);
lcd.print("15m ");
}
if (data[0] == 25){
lcd.setCursor(6, 0);
lcd.print("12m ");
}
if (data[0] == 27){
lcd.setCursor(6, 0);
lcd.print("10m ");
}
if (data[0] == 26){
lcd.setCursor(6, 0);
lcd.print("11m ");
}
// VFO-A band instÀllning och utskrift
if (data[16] == 4){
lcd.setCursor(6, 1);
lcd.print("160m ");
}
if (data[16] == 8){
lcd.setCursor(6, 1);
lcd.print("80m ");
}
if (data[16] == 11){
lcd.setCursor(6, 1);
lcd.print("40m");
}
if (data[16] == 14){
lcd.setCursor(6, 1);
lcd.print("30m ");
}
if (data[16] == 17){
lcd.setCursor(6, 1);
lcd.print("20m ");
}
if (data[16] == 20){
lcd.setCursor(6, 1);
lcd.print("17m ");
}
if (data[16] == 22){
lcd.setCursor(6, 1);
lcd.print("15m ");
}
if (data[16] == 25){
lcd.setCursor(6, 1);
lcd.print("12m ");
}
if (data[16] == 27){
lcd.setCursor(6, 1);
lcd.print("10m ");
}
if (data[16] == 26){
lcd.setCursor(6, 1);
lcd.print("11m ");
}
// VFO-B band instÀllning och utskrift
}
}
The code is really simple but it works and I'm happy with it. The output of these different if-statements are to pull relays and control a antenna shifter. The complicated thing was to know when to start recieve and to just recieve 32 bytes after that. That turned out pretty good I would say. Using a array for the 32 bytes and then checking the element with index 0 and 16.
The code isn't done completely done but now I just need to add the different outputs and set them to HIGH when it should be HIGH. I've put the LED there only to show a output.
The one thing that "did" it was actually using a RS232/TTL level shifter. Without it you can't do anything serial related with arduino. Another reflection is also how few examples there is on the Arduino website on using Serial related commands. Why is it that a person needed to explain how to work with serial communications with the Arduino on the forum? Shouldn't it exist enough information on the comands on the official website that allready presents all of them?
Thanks for all the answers and help!
It was highly appreciated
// Oscar