I'm using arduino to communicate with FPGA so that if I type special command on the serial monitor, FPGA will make the corresponding output. It occurs without any specific arduino code.
(i.e. I have to type "0100" on the arduino serial monitor to make FPGA have output of "1011", something like that)
What I want to do is to make the command automatically sent to the arduino board via serial monitor using loop.
So far, I couldn't figure out any other way of sending data without typing...
Could you please give me some advice on this?
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?
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");
}
}
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.
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.
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.
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.
@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.