Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 15:56 15 May 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 : MicroMite and RasPi

Author Message
dasyar
Regular Member

Joined: 13/04/2015
Location: United States
Posts: 58
Posted: 01:50am 23 May 2015
Copy link to clipboard 
Print this post

I have, on a breadboard, a MM 28 pin setup, which I have hooked up to a Raspberry Pi via the GPIO /dev/ttyAMA0. I am using minicom, on the Raspberry Pi, to access the MM, which so far is working as expected.

The question I have, to expand the Raspberry Pi functionality, by using the MM, can I, maybe using Python or C, or whatever, get direct access and control of the devices/sensors that could be attached to the MM, in real time?

Since I have an LED attached to pin 16, what would a program look like to maybe turn on/off the LED, from a program on the Raspberry Pi, as an experiment?

I am also aware of MMedit, which is only available for Windows, but that seems to go through a procedure of actually programming the MM chip. So, it is almost looking like what I would like to do, not possible, just want to confirm.

Thanks
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 02:08am 23 May 2015
Copy link to clipboard 
Print this post

the simplest approach is to write an mmbasic program that responds to simple text commands sent from the RPi. for example, you might use the following codes:

"2+" : set pin 2 high
"2-" : set pin 2 low

then from your python program just write the strings "2+" or "2-" to the serial port to turn an LED attached to pin 2 of the micromite on or off.

you could develop quite a complicated language for communicating between the two devices. but start with something simple.


cheers,
rob :-)
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 09:01am 23 May 2015
Copy link to clipboard 
Print this post

How about just sending an immediate mode command? Just a string out the pi comm port for the MM to execute immediately? No program running on the MM.

Micromites and Maximites! - Beginning Maximite
 
Tim036
Newbie

Joined: 25/11/2014
Location: United Kingdom
Posts: 17
Posted: 12:06pm 23 May 2015
Copy link to clipboard 
Print this post

As an aside to this thread, I've found from an RPi to MictoMite, this works fine:-

picocom /dev/ttyUSB0 -b 38400 -l (lower case L)

(well worth installing picocom first *LOL*)

Tim
 
dasyar
Regular Member

Joined: 13/04/2015
Location: United States
Posts: 58
Posted: 12:22am 24 May 2015
Copy link to clipboard 
Print this post

  Quote  
How about just sending an immediate mode command?

Since I am very new with this, how is that done, maybe an example.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 03:09am 24 May 2015
Copy link to clipboard 
Print this post

  Quote  Since I am very new with this, how is that done, maybe an example.


dasyar, you do need to get stuck into the manual, it is very readable and all the information is in there.

However - to get you going - all Basic commands can be sent from the console as well as appearing in programs. So to turn on and off an LED you need to go:

SETPIN 16,DOUT
pin(16)=1
pin(16)=0

The first command configures pin 16 as an output. The second sets the pin to a high level. The third sets it low.

You could also do things like:
SETPIN 2,AIN
print pin(2)

The first command sets the pin as an analogue input
The second prints the value of the voltage on the input


All this is in the manual



 
dasyar
Regular Member

Joined: 13/04/2015
Location: United States
Posts: 58
Posted: 09:08am 24 May 2015
Copy link to clipboard 
Print this post

What threw me was "immediate mode command", yes I have been reading the manual, and aware of some the commands. I thought "immediate mode command" was something that you could issue from, lets say a com1 or com2 interaction.

I do not remember reading this in the manual, but can MM do threads or tasking? A task could be something like a temperature reading every 10 seconds and the reading gets placed into global variable where a main program or other tasks could read it. Of course the main program or task is running almost independently of each other.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 11:21am 24 May 2015
Copy link to clipboard 
Print this post

@dasyar,

Not really threads or tasking, but to achieve something like you mention you can use the SETTICK command which effectively is an interrupt that is called at specified intervals; so within the interrupt routine you can do something like read a temperature, and in turn update a global variable for use by the main program.

The manual explains the SETTICK command in detail

WW

For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
dasyar
Regular Member

Joined: 13/04/2015
Location: United States
Posts: 58
Posted: 02:38am 25 May 2015
Copy link to clipboard 
Print this post

I wanted to do a test run of something that would access the MM Console mode from a program. The program below uses freeBasic and is set up to do a simulated script routine. And to my surprise, it worked as expected.

All this is in hopes that when somebody comes up with a MicroMite HAT PCB for the Raspberry Pi , I will have some general knowledge as to how too work with it, at least I will know what my options are.

This seems to be feasible, you have the MM do its thing, while you can use all the Linux resources to support the MicroMite. At least this looks like a sound idea to me.



'MMledScript.bas
' Using freeBasic for the Raspberry Pi.
' Pseudo script program to be run with MicroMite Console hook up.

Open Com "/dev/ttyAMA0:38400,n,8,1,cs0,ds0,cd0,rs" As #1

IF Err <> 0 then
Print "Error opening port..."
goto finis
End if

Print #1, "NEW" ' Send with CR
sleep 3000,0 ' Sleep for three seconds
print #1, "SETPIN 15, DOUT" ' Send with CR
sleep 100,0 ' Pause for setup
print #1, "PIN(15) = 1" ' Turn on LED on pin 15, send with CR
sleep 3000,0 ' Sleep for three seconds
print #1, "PIN(15) = 0" ' Turn off LED on pin 15, send with CR



finis:
print "Closing Port!"
'close the port(s)
Close
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 03:15am 25 May 2015
Copy link to clipboard 
Print this post

Agghh, all that power just to turn on/off a LED.

When you get further into it you could have a program running on the Micromite that will take your commands and do all the flashing/whatever for you.

Geoff
Geoff Graham - http://geoffg.net
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 03:24am 25 May 2015
Copy link to clipboard 
Print this post

maybe you could implement the I2C example in the manual to get an idea of using the uMite as a "port expander" type thing so you can see how the uMite could be running things and you are just throwing commands at it. Just a thought....
 
dasyar
Regular Member

Joined: 13/04/2015
Location: United States
Posts: 58
Posted: 03:43am 25 May 2015
Copy link to clipboard 
Print this post

I already did an experiment where you use the Micromite as a stand-alone set up. I had a program that did some IO with an XBee attached to COM2, so from my desktop attached XBee, I could turn on/off an LED, on the MM breadboard setup, as a test.

It was suggested in an earlier post about doing some kind of control program on the MM to work with a login on COM1 or COM2. Just experimenting with some different ideas.

I do not make PCB boards, I stay away from doing any kits that require any soldering. Just a hobby to keep me interested in my retirement years.
 
Print this page


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

© JAQ Software 2024