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 StatesPosts: 58 |
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 ZealandPosts: 2294 |
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 StatesPosts: 1421 |
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 KingdomPosts: 17 |
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 StatesPosts: 58 |
Since I am very new with this, how is that done, maybe an example. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
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 StatesPosts: 58 |
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 KingdomPosts: 2794 |
@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 StatesPosts: 58 |
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: AustraliaPosts: 3165 |
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 StatesPosts: 925 |
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 StatesPosts: 58 |
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 |