How to send data from Microsoft Excel into propeller cog
zpua
Posts: 33
Hello,
I would like to pass data from microsoft excel into propeller and put them in array form.
The reason I want to do this is because I want to compare get a difference between my data in Excel
and data in propeller cog in array form.
According to the advice from experts, I could do it through MicroSD card or activate the visual basic program that built into the Excel. Since I am not able to insert a SD card into my propeller demo board, so I think VBA is the only way for me to do so.
Can anyone gives me some ideas on how can I get this project work?
Thank you.
I would like to pass data from microsoft excel into propeller and put them in array form.
The reason I want to do this is because I want to compare get a difference between my data in Excel
and data in propeller cog in array form.
According to the advice from experts, I could do it through MicroSD card or activate the visual basic program that built into the Excel. Since I am not able to insert a SD card into my propeller demo board, so I think VBA is the only way for me to do so.
Can anyone gives me some ideas on how can I get this project work?
Thank you.
Comments
1. Save the data from Excel to a .csv format file, or copy it from the spreadsheet, paste it into Notepad, and save it as text which will be tab delimited.
2. Write a Spin program to receive the incoming text with FullDuplexSerial and parse it into an array.
3. Open the download cable port (the PropTool tells you which COM port it is emulating) with Hyperterminal and use Transfer -- Send Text file to transmit it over the "serial" port.
The two hardest keys to this for a newbie will be learning to control fullduplexserial to send and receive data, and parsing the incoming data since there are no native Spin functions to take, say, the characters 4, 1, and 9 and assemble them into the decimal value 419 -- you have to do it yourself. It's not hard, but does require knowing Spin pretty well.
Thanks for you comments. I have saved my 100 data in Notepad as tab delimited format.
Do you have any example spin code that will receive the incoming text and parse them into array form that I can review on it?
Thank you.
Can you be more specific?
How often will the data in the excel file change?
How often will the Propeller data change?
When you compare the data, what are you comparing? Adding? Subtracting?
Bruce
I believe it would be easier to use FullDuplexSerial to send Propeller data to the terminal, and use Windows functions in C++ to get your data and arrange it the way you want it. And then parse it against a csv file.
Bruce
Let say I have 100 data in Excel and 100 data running in propeller,once propeller get data from excel, I want both data in array form get a differences such as:
REPEAT I from 0 to 100
Array3:=Array2-Array1
Does it making any sense?
zpua
If the first answer is no, and the second answer is yes, then all you need is a small C++ dialog box program to enter values to compare against the Propeller data.
I would imagine you could even send new data from this dialog box program to the serial terminal, which in turn would send it to the propeller to act upon it.
Bruce
Bruce
I don't understand what you mean by having a small c++ dialog box program, is it another programming tool that I have to use?
Can I get the data in csv format by using only spin code?
zpua
The quick answer is yes, but how often will this csv file need to be changed?
http://dev.emcelettronica.com/serial-port-communication-excel-vba
and just fullduplexserial on the Prop...
Are you comparing the data within the Propeller chip?
OR
Are you comparing the data within Excel?
It almost sounds like he does not need FullDuplexSerial with the information you provided.
Bruce
PS Good find
I would like to compare the data within the propeller chip.
Then, just select the first three columns, do a copy, and paste the data into your DAT section:
The paste operation will put tabs between the column data so it formats okay for the compiler.
-Phil
That could be a real blessing or a real pain depending on his true needs. However, your method is probably the easiest for a newbie. But if his data is horizontal as compared to vertical, then perhaps a csv file, a parsing routine, and the FILE directive might be a better solution.
Bruce
http://forums.parallax.com/showthread.php?131469-Exchange-data-with-Microsoft-Excel-(Need-some-people-to-test-this...)
I still have some confusion. If I do what you taught, do I still need to edit the visual basic code in Excel?
Bruce,
My data is in vertical form, but I would like to learn FILE directive method as well.
Phil's example is by far the easiest. Of course it uses fixed data and will need a recompile and reload of the program into the prop each time the data changes. However, this is probably no different to the complexity of using a serial object (such as FullDuplexSerial) to receive the file each time, and saves a lot of programming.
Here is an alternative, but of course is a lot more complex...
In excel, format your data as fixed length, then save as a tab delimited file (or if you are proficient in VB, you can use VBA to output straight to the comm port and into the propeller). Use FullDuplexSerial on the prop to receive the data. Provided you use fixed lengths, you should be able to parse the data quite simply in spin, and store the data arrays.
Most important question is: do the values change all the time or are they constant (or at least constant for three months)?
If the values change often, it makes sence that Excel sends the values to the propeller through a serial connection.
If the values are constant Phi-Pi's suggestion is good.
Anyway please give the forum an overview about your project. Make your description rich with a lot of details.
Posting it short does only produce new questions, wrong assumptions and inapropriate suggestions.
keep the questions coming
best regards
Stefan
To expedite the answer, the answer is no.
Thanks for the feedback. Here is an overview of my project.
Basically, I already have a set of data execute by propeller in spin generates sin(0) to sin(180) store in Array form.
Now, I have a set of fixed data in Excel. It has the same number of elements of data in propeller. I do not intend to change the data in Excel in this practice. So I think Phil's suggestion might be easiest here, but I still do not know how can I assign them in array form in DAT.
Once I get the data from excel in array form, I can get the difference between value in sine() executed by propeller and data from excel.
I guess I could try VBA as well, it's all depend on which method make sense to me.
Thank you.
This is all about what I intend to do. Thank you.
I don't think it sends data in array form, but arranging the data into an array can probably be done on the prop
DAT
MYVAL LONG 1,2,3,4
PUB
V=LONG[@MYVAL][3] 'V is set to 4
As localroger points out, your data will already be in array form once you paste them into your DAT section, whether they be comma-separated or one datum per line. All you have to decide is whether you want bytes, words, or longs and set up the second column of your Excel form accordingly.
-Phil
I was wondering how long it take someone to mention that!
... Tim
it's up to you how many details you tell us. I don't think that calculating sinus and cosinus values are a selfpurpose. You are doing something with them.
So to give a real overview about your project is answering the question what are you doing in the end?
By the way: The propeller-chip has inbuild sinus and cosinus tables in the ROM. And there are objects in the obex how to access these sin-cos-values.
If your project somehow does trigonometric calculations this will be very useful.
And again this is an example how giving an overview and giving details opens up for new and better suiting solutions
keep the questions coming
best regards
Stefan