Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arduino or other board with Microsoft Foxpro

JacobR92

Technical User
Dec 10, 2024
12
Hi,
I would like to know if i can read an arduino sketch or other microntroller on Microsoft Foxpro.

My objective is read the data in foxpro with a plot sended from a board. Is it possible to do?

thanks to advance
 
Hello ,

Yes you can, you need a seral output from your controller and a procedure on Foxpro to get the Raw data from the micro and well process them.


Here is a start
 
I've never used devices like that with FoxPro, but as long as you can communicate with it via a standard protocol, you should be able to open a connection to it using some standard protocol like http or ftp.

For example if it uses http, you can create an object to talk to it using CREATEOBJECT("WinHttp.WinHttpRequest.5.1").
 
You can communicate with the Arduino using the MSComm32 control in Visual FoxPro. Make sure to register it using the regsvr32 command.Then, check the COM port assigned to the Arduino in the Windows Device Manager to identify the correct port to use.


sample foxpro:

PUBLIC oForm
oForm = CREATEOBJECT("Form")
oForm.ADDOBJECT("comm", "olecontrol", "MSCommLib.MSComm")

WITH oForm.comm
.CommPort = 1 && Set to your COM port number
.Settings = "9600,N,8,1" && Match baud rate and settings
.PortOpen = .T. && Open the port
ENDWITH

* Send "Hello World" to Arduino
oForm.comm.Output = "Hello World" + CHR(13) + CHR(10)


arduino side:

void setup() {
Serial.begin(9600); // Set baud rate to 9600
}

void loop() {
if (Serial.available() > 0) {
String data = Serial.readStringUntil('\n');
Serial.println("Received: " + data); // Echo received data back to Visual FoxPro
}
}
 

Pieter Koemans Programmer​

the process seems to work. Thank you!
If i want to visualize the data send to my Board with the sensor. What can i do?
 
Foxpro isn't fast enough to render graphs in realtime. For that you should use activex controls.
But you can "catch" data in the background and plot it with foxcharts.
To catch data in the background make sure you use the oncomm event in mscomm32
 
Thanks!
I would like to ask one last thing.

With Which active X control or External library can I do the graph and read the data?
 
That depends on what output rate your arduino is and also how fast you want to update..
What is your application?
 
My application consists to connect a string pot to arduino and find the data of position and put all in a plot.

I know there are other applications to do this kind of work.

but I feel much better with foxpro because later I could also compile it and make it become an exe.
 
You can communicate with the Arduino using the MSComm32 control in Visual FoxPro. Make sure to register it using the regsvr32 command.Then, check the COM port assigned to the Arduino in the Windows Device Manager to identify the correct port to use.


sample foxpro:

PUBLIC oForm
oForm = CREATEOBJECT("Form")
oForm.ADDOBJECT("comm", "olecontrol", "MSCommLib.MSComm")

WITH oForm.comm
.CommPort = 1 && Set to your COM port number
.Settings = "9600,N,8,1" && Match baud rate and settings
.PortOpen = .T. && Open the port
ENDWITH

* Send "Hello World" to Arduino
oForm.comm.Output = "Hello World" + CHR(13) + CHR(10)


arduino side:

void setup() {
Serial.begin(9600); // Set baud rate to 9600
}

void loop() {
if (Serial.available() > 0) {
String data = Serial.readStringUntil('\n');
Serial.println("Received: " + data); // Echo received data back to Visual FoxPro
}
}
Thank you for posting the code, some food for thought in there for me!
 
I use VFP for my Amateur Radio application (Logbook Database and Radio Transceiver Control using MSComm) and I am in the process of building an Arduino Application that will also send commands to the Radio Transceiver via the VFP Application (to avoid a COM Port conflict).
 
ok thank you!

Now I'm in a slightly different situation.
The work done before was cancelled. However, I managed to get the Arduino code to insert and the Foxpro code.
I share it many times if it helps someone.

the problem at the moment is being able to see the data coming out of the Arduino.
What tool can I use to see what comes out of Mscomm and the Arduino board?

I'll explain better. Instead of implementing them in a graph (as I said before) I could see the data arrive on a display or table.

What can I use?

And above all, how can I implement this tool for receiving data from my Arduino sensor?


the code:

sample foxpro:

PUBLIC oForm
oForm = CREATEOBJECT("Form")
oForm.ADDOBJECT("comm", "olecontrol", "MSCommLib.MSComm")

WITH oForm.comm
.CommPort = 1 && Set to your COM port number
.Settings = "9600,N,8,1" && Match baud rate and settings
.PortOpen = .T. && Open the port
ENDWITH

* Send "Hello World" to Arduino
oForm.comm.Output = "Hello World" + CHR(13) + CHR(10)


arduino side:

void setup() {
Serial.begin(9600); // Set baud rate to 9600
}

void loop() {
if (Serial.available() > 0) {
String data = Serial.readStringUntil('\n');
Serial.println("Received: " + data); // Echo received data back to Visual FoxPro
}
}
 
To gain a better understanding of how to process the data, it would be helpful if you could share the data format that you're sending from the Arduino to FoxPro.
 

Pieter Koemans


Sorry, I explained me badly.

At the moment i am not able to see the data.

How tool can I use for see the data send from my arduino board?

A query? A graph? And if I send the data on foxpro, where I put the code for foxpro?
 
You can view the data in the Serial Monitor of the Arduino IDE. All output you send to Visual FoxPro while streaming the data should be visible in the built-in Serial Monitor function of the Arduino IDE. If you do not see the data in the Serial Monitor, then FoxPro will not see the data either.To open the Serial Monitor and view the data:
  1. Make sure you have included Serial.begin(9600); in the setup() function of your Arduino sketch.
  2. Upload your sketch to the Arduino.
  3. Click on the Serial Monitor icon in the top right corner of the Arduino IDE.
  4. Set the baud rate in the Serial Monitor to the same value as in your sketch (for example, 9600).
If you use Serial.print("Hello world") or Serial.println("hello world") in your Arduino code, the output will appear in the Serial Monitor window
 

Part and Inventory Search

Sponsor

Back
Top