How to send commands without typing it on the serial monitor?

Hi! @gcjr

I'm not the one who designed the system so not 100 percent sure,
but I think Arduino and fpga are connected by default serial because the code I upload on the arduino is opening default serial (by just calling Serial.begin(baudrate).

If you mean serial 1 = defult serial, then yes.
Does this answer your question?

how can you communicate with the Arduino via the PC using the "Serial" interface if the "Serial" interface is connected to the FPGA ?

posting your code (using "</>") would help

Oh, I think I got your question wrong. I think they are then connected by physical means, that inputs/outputs are all connected to FPGA by wires (embeded in the large board).

btw, I really don't think this code would help anything, but still upload.
I'm just using arduino as serial communicator & ADC.


int adc = 0;
int ADC_0,ADC_1;

void setup() {
  Serial.begin(115200);
  pinMode(7,INPUT);
  ADC->ADC_MR |= 0x80; // Mode FREERUN
  ADC->ADC_CR = 2; // Start converter
  ADC->ADC_CHER = 0xFF; // Enabling channels
}

void loop() {
  
  if((PIOC -> PIO_PDSR & 0b00000000100000000000000000000000)>>23 == HIGH){
  ADC_0 = ADC->ADC_CDR[7];// read data on A0
  ADC_1 = ADC->ADC_CDR[6];// read data on A1

  Serial.print("ADC0 Value =");
  Serial.print(ADC_0 / 4 );
  Serial.print(", ADC1 Value =");
  Serial.print(ADC_1 / 4);
  
  Serial.print("\n");
  Serial.print("\n");

  }
}

the posted code doesn't read the serial monitor and i don't believe it shows any output that could possibly be to the FPGA

Well, but that is how my board works...

How about changing my question into this:

Would there be a way of sending string data directly to the port without using serial monitor?

i don't see where that's done in the code unless it's those prints (e.g. "ADC0 Value = ") which are already occurring

Hi,

I want to send data string without using typing it on the serial monitor.
Would there be any way of doing this?
For example, if I entered "a" on the serial monitor,
string command "1001" should be sent to the port automatically as if I'm entering it on the serial monitor and pressing send button.

Thank you.

Using the IDE's serial monitor, I don't think so. It's possible that a more full featured terminal program might have some Macro expansion features, check a few of them out.

Alternatively, you can write your own program on your PC in you language of choice that talks to the Arduino over Serial and then you can build a custom interface that sends whatever you like.

Hi @wildbill,

Alternatively, you can write your own program on your PC in you language of choice that talks to the Arduino over Serial and then you can build a custom interface that sends whatever you like.

Do you mean something like PySerial using python?
Actually, I have been trying to use it, but I confronted some weird problem there.

Whenever I do serial.write() (which a function for sending data), nothing occurs. But the expected output comes out when I turn on the serial monitor on IDE...

Here is some of my code of python using pyserial:

import pandas as pd
import serial
import time

arduino = serial.Serial(port='/dev/cu.usbmodem14101', baudrate=115200, timeout=10,write_timeout=10)
time.sleep(2)
arduino.flush()

if arduino.isOpen():
  #this is function for sending data 
    send_data(arduino,"hello")
    print("1st input done")
    time.sleep(4)

    a = arduino.readline().decode().strip()
    print(a)
    if "me too" in a :
        print("success")
    else:
        print("failed")
    arduino.close()

in Arduino, I programmed it to print "me too" when it receives "hello" string.
So the thing is, whenever I run this code on python, always this code ends up printing "failed".
But when I turn on the serial monitor from IDE, suddenly "me too" word pops up from the serial monitor.

you're cross posting

Hi, I think I should delete the post you mentioned since it's confusing. Thanks for pointing this out!

Can't you do the translation in the Arduino? Send and receive an "a" but use "1001" or whatever.

Hi @sionaggutraidh
Could you be more specific? What do you mean by translation in the Arduino?

Just some kind of if statement perhaps, if an a is received, make the string to be used = 1001. If what arrives is a b, string to be used = 1100 or whatever.

Or switch...case.

@mimikm

TOPIC MERGED.

Could you take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum.

@sionaggutraidh
I think I could do that, but how can you send that string (ie "1001") back to serial monitor?
I don't need this to be printed on the serial monitor at all, but just to be sent to the serial port.

Since the merging of topics I'm even more confused than before.

I thought you wanted a short hand way to send 1001 by typing a, not 1001. Your thought was to do that in the pc, type a, send 1001. Mine was to do it in the Arduino, type a, send a, use 1001 internally. I'm not clear on where the fpga fits in.

Give us a block diagram of what's going on here?

Easy to do from a smart phone using Bluetooth.

please find out how the Arduino communicates with the FPGA

tips how to improve your posting style

1 Like