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!

Insert data of Arduino on a plot 1

JacobR92

Technical User
Dec 10, 2024
12
Good evening,

I have a question about Foxpro. My objective is implement a plot with the data sent from Arduino board.
I would like to do everything with Foxpro 9.0 and the library foxcharts.
I have the code for send the data from Arduino to Foxpro. But i don't know how to implement the plot.

Can anyone help me?

Thanks in advance
 
Here's an introduction article on Foxcharts: https://doughennig.com/papers/Pub/FoxCharts.pdf
As shown already in the first example of a bar chart a fox chart takes a workarea as data source:

See On Page 4
.SourceAlias = 'ChartData'
So it's quite simple to use.

Go to https://github.com/VFPX/FoxCharts
Click on the green Code button and pick "Download ZIP" and you have the FoxCharts including source code and one FoxCharts Documentation - A Tutorial.doc which documents all you need to know in the first place.
 
Can you let the Arduino board do its job and send or receive data as you have established and then put that into a cursor or DBF? Split it up into time vs signal value and you have your plot coordinates. And then the question is whether this comes over as integers, floats, strings, with dot or comma as decimal point, with scientific notification (1e-9, for example) or not, etc.

In the end you better prepare to have some numeric values for both plot axes, no matter if you want a barchart, a line chart or whatever, you need coordinates and one obviously is the time of measurement and the other is your measurement, isn't it?
 

Chris Miller

Can you let the Arduino board do its job and send or receive data as you have established and then put that into a cursor or DBF?

I need to implement my project on a DBF.


In the end you better prepare to have some numeric values for both plot axes, no matter if you want a barchart, a line chart or whatever, you need coordinates and one obviously is the time of measurement and the other is your measurement, isn't it?

Yes. i need to insert the data from an arduino board connected to a string pot.
And manipolate the data of the chart.
 
I need to implement my project on a DBF.
I said cursor or DBF, so DBF is fine.

i need to insert the data from an arduino board connected to a string pot.
You said you have the part done about receiving the data from the Arduino board. So when that's done you have the data. To plot that is completely independent, so what's your problem, now? Understanding the foxcharts component?
 
You said you have the part done about receiving the data from the Arduino board. So when that's done you have the data. To plot that is completely independent, so what's your problem, now? Understanding the foxcharts component?


My problem si I can't make a display or graph with which to see the data. In particular for the graph I wouldn't know how to implement it programmatically.

How can I implement code that makes me see data on a graph?
 
You've been pointed to foxcharts examples and documentation. It visualizes data in any way you want - pie chart, bar graph, line graph, scatter plot, whatever.

https://doughennig.com/papers/Pub/FoxCharts.pdf is a good introduction. So click on the link and read the PDF, apply it on your computer and get it going. Don't just copy and paste code and try to run it, read the text and follow the instructions step by step and you get going with foxcharts and learn to apply it to the northwind sample data you have in your VFP installation and later to your own data.
 
Last edited:
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
}
}
 
You should solve thqat problem in the other thread you dedicated to the data transfer, so Pieter Koemans sees you have a question about his code.

You should receive data into a DBF first, because that's the basis of foxcharts, a workarea with data. If you want to plot while you receive, the data retrieval and graph generation can be interleaved, if you take a closer look into the foxcharts code it has a line .DrawChart()

While you receive data and add more and more data points into the DBF you call that and the plot gets updated.

You already cut your problem into two separate parts, stay with this and interleave the two things at the end. Get one thing going after the other. If you start with the data retrieval part and not the chart, then have a browse of the DBF you use for store the incoming data and that'll be your first developer view on the data treceival process. There is no need to solve two problems at once.
 

Part and Inventory Search

Sponsor

Back
Top