Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:25 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Serial communication

Author Message
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 03:20pm 27 Jun 2013
Copy link to clipboard 
Print this post

Hello all,
I was wondering if there was a way to send a program from a computer to run on a duinomite mega then send results back to the computer, I'm pretty sure that I will need to use a seriel port but I am not sure which one. I was wondering if I would be able to use the USB connector as my com port or perhaps the rs232 port. Any suggestions?

Thanks
Adam
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 10:01pm 27 Jun 2013
Copy link to clipboard 
Print this post

MMIDE (first result http://www.circuitgizmos.com/files/begmax.pdf, page 21) already does just that.

The computer "sees" a duinomite (or maximite) as a serial port on the USB, so in theory any serial port program (including one written by yourself) should work.
 
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 11:01pm 27 Jun 2013
Copy link to clipboard 
Print this post

he is what i have but I have been unsuccessful in getting any response

here is what I have, the COM port on the computer that the duinomite is connected to is COM 5
Imports System.IO.Ports
Module Module1

Private mySerialPort As New SerialPort
Private Sub CommPortSetup()
With mySerialPort
.PortName = "COM5"
.BaudRate = 9600
.DataBits = 8
.Parity = Parity.None
.StopBits = StopBits.One
.Handshake = Handshake.None
End With
End Sub
Sub main()
Dim message As String
message = Console.ReadLine()
Dim MyPortNames() As String
MyPortNames = SerialPort.GetPortNames
Dim port As SerialPort
port.Write(message)
End Sub

End Module


what should i send to the duinomite for it to say print "hello world"?
would i send the PRINT function?

thanks
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 08:20am 28 Jun 2013
Copy link to clipboard 
Print this post

Interesting request. You might need a 'master' program running on the Maximite that receives the 'slave' program sent from the pc, saves it to the SD card then runs that program. Somehow the master program needs to regain control after the slave program finishes, or the slave program must be written so that it gives back control - perhaps as a loadable module or ...
Visit Vegipete's *Mite Library for cool programs.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 08:37am 28 Jun 2013
Copy link to clipboard 
Print this post

See Dylan's reply. You can just do the same as MMIDE.

Why do you want to? Wouldn't you be reinventing it?

John
 
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 10:17am 28 Jun 2013
Copy link to clipboard 
Print this post

What I'm trying to do is this

Have the pc select a value from an excel spreadsheet

Send that value to the maximite for it to the run a program which sets three different digipots then reads a current value. Then that current value is sent back to the pc to be matched on the same excel spreadsheet. It then runs through all the values until completed. The reason I wish to I cooperated the pc is so as I can have a system where the values are constantly up to date and new documents can be added to the main system. Without having to convert to say .csv and transfer to maximites sd card.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 11:02am 28 Jun 2013
Copy link to clipboard 
Print this post

You don't need to load the program from the PC. Just exchange the data.

John
 
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 11:58am 28 Jun 2013
Copy link to clipboard 
Print this post

Okay. Thanks.
Would I be able to run two simultaneous program's. one that sends and receives the data on the pc and another that does the calculations. My only issue is actually making the connection.

Adam
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 11:32pm 28 Jun 2013
Copy link to clipboard 
Print this post

Can you connect using MMIDE? Because you want those settings.

An alternative to programming from within Excel is to use automation:
http://wiki.freepascal.org/Office_Automation#Reading.2FWriti ng_an_Excel_file_using_OLE

This way the same program can also do your serial communication, have a nice UI, etc.
http://wiki.freepascal.org/Hardware_Access#Serial_Communicat ion

There are a lot of ways to use two programs. The simplest is perhaps for them to share a text file. A pipe is another option. OLE (as suggested above) is a more complex variation of COM. CORBA is similar to COM. A (web) server somewhere might also be an option, one which I happen to be about to choose for a vaguely similar project. :)
 
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 08:22pm 29 Jun 2013
Copy link to clipboard 
Print this post

well I made a bit of progress,

I have managed to type text on the duinomite through the pc my sending it through a program.

I guess the next step is to get it to run a program that is stored on the duinomite then send results back.

little by little.

thanks for your help guys if i come across anything else I'll let you know.

Adam
 
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 08:47pm 29 Jun 2013
Copy link to clipboard 
Print this post

thought just came up

is there any way to say send the return/enter key as a command say

RUN "test.bas"

and then simulate the return key to run the program stored on the dunimite?

Adam
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 11:14pm 29 Jun 2013
Copy link to clipboard 
Print this post

The enter key does a lot of work, not just on a PC, but even more so when used for serial communications.

Under Windows, it generates CR/LF (Carriage Return/Line Feed), two ASCII "characters" that live below 32 (space bar). When you type any other character, it will appear in whatever program you are using (assuming of course that it is one you can enter text into).

When that program is serial, it generally doesn't send whatever you've typed until you press enter. And then it sends the whole kit and caboodle - along with CR and/or LF - across the wire.

Incidentally, one nice feature of the Duinomite is that at the command prompt you can simply type "test<enter>" and it will run test.bas!

On a completely different note, but not worth their own thread: two things I am missing in 4.3 compared to 2.7 are SETUP (which - inter alia - allowed me to change serial settings) and HELP (which was helpful). Is there a reason these were removed, or am I just missing something obvious?
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 01:08pm 30 Jun 2013
Copy link to clipboard 
Print this post

  Dylan said  

On a completely different note, but not worth their own thread: two things I am missing in 4.3 compared to 2.7 are SETUP (which - inter alia - allowed me to change serial settings) and HELP (which was helpful). Is there a reason these were removed, or am I just missing something obvious?


SETUP and HELP were never in the main MMBasic lineup.
They were in a Duinomite fork only and it didn't progress past V2.7 or so.

Jim
VK7JH
MMedit   MMBasic Help
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 03:17pm 30 Jun 2013
Copy link to clipboard 
Print this post

  Dylan said  
On a completely different note, but not worth their own thread: two things I am missing in 4.3 compared to 2.7 are SETUP (which - inter alia - allowed me to change serial settings) and HELP (which was helpful). Is there a reason these were removed, or am I just missing something obvious?


Hi Dylan,

Without mentioning the `war'... Historically The DM was designed by Olimex.com as a similar, albeit different pinout, device to the original MM. The MMBasic that Geoff released as open source was altered to branch off in a sightly different direction than the MM and was changed to DMBasic to reflect that deviation... As a consequence different commands and features were written into the DMBasic that werent included in MMBasic... This is commonly called FORKING ie branching off in a different direction to the original..

When Geoff released MMBasic 3.0 as `closed source' The DM group were unable to use his firmware anymore from then on and as a consequence of the licensing conditions of `open source' that DM was released under Geoff was unable (even IF he wanted to use them, which he probably didn't) to incorporate any DM code in his MMBasic offering.

This was basically the end of DMBasic development as Geoff introduced (and is still improving things) many new features that the DM Group were unable to `copy/rewrite or even keep up with' and thus development ceased at a fairly stable and still quite usable ver (1.7 I think) The 2.7 refers to the MMBasic version that DM was based on.. Yes very confusing isnt it..

The bottom line is DMBasic is no longer updated, although all the source is available for download from GitHub for anyone who wants to dabble...

MMBasic source is readily available via request and I believe ok to modify for personal use but permission is required for any distribution further than personal use.

Hope this clears it up a bit.

Regards,

Mick





Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
FuzzyPanda
Newbie

Joined: 24/06/2013
Location: Australia
Posts: 9
Posted: 11:44pm 01 Jul 2013
Copy link to clipboard 
Print this post

Well after a a bit of fiddling with the debug console on mmide i found out how to do the carriage return/line feed.....

as HEX...

when looking at the debug console and sending the run command using the run button on mmide is found that if i send a HEX value of 72 75 6E 0A 3E 20 that it printed run and then "pressed" return. the HEX value above however give run LF/SP

I then changed the HEX value to 72 75 6E 0D 3E 0A
which is run CR/LF which also worked.

should i now leave it like that i just send the hex value of 0D 3E 0A or 0A 3E 20 whenever I want the return key "pressed"? or is there a better way. I'm happy enough to leave it as it has gotten the desired result.
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 12:32am 02 Jul 2013
Copy link to clipboard 
Print this post

whatever works is OK but you could probably get away with just 0D0A, that is CR LF.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024