Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:48 13 Jul 2025 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 : Help with mm Basic

Author Message
Benzol
Regular Member

Joined: 07/01/2015
Location: Australia
Posts: 64
Posted: 02:09am 30 Mar 2015
Copy link to clipboard 
Print this post

Hi All
I am slowly trying to get my time lapse photography project going but need a bit of help. i am learning basic via FastBasic on the internet but trying to get my program to work following an input has me beat. I assume it is the same as enabling a DOUT so the I/O waits for a voltage on that pin but i can't get the syntax correct. I also can't get the autorun option to work so i can use the mm standalone.
Can someone please point me in the right direction?
Thanks
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9593
Posted: 02:28am 30 Mar 2015
Copy link to clipboard 
Print this post

More details would be helpful, such as:

- What are you trying to detect? A high/low transition on an I/O pin? A certain value of analog voltage on an input pin?
- What do you need to have happen once the MM is tripped?

Edited by Grogster 2015-03-31
Smoke makes things work. When the smoke gets out, it stops!
 
Benzol
Regular Member

Joined: 07/01/2015
Location: Australia
Posts: 64
Posted: 02:35am 30 Mar 2015
Copy link to clipboard 
Print this post

Hi Grogster. I am using a Canon remote timer to set the process off. it goes high (+3v) then the mm triggers a camera via a relay to start taking photos at a set rate. that's the easy bit. i just can't get the syntax right to recognise the input and start the camera trigger.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1576
Posted: 02:41am 30 Mar 2015
Copy link to clipboard 
Print this post

Autorun

Please read page 10 of Geoffs user manual for Micromite MkII.


  Quote  To do this you first need to regain the command prompt and you can do this by entering CTRL-C at the console. This will interrupt the running program and return you to the command prompt.
Then enter the command:

OPTION AUTORUN ON

This will instruct MMBasic to automatically run your program whenever power is applied. To test this you can remove the power and then re apply it.


I can't better say that!

Regards
Michael
causality ≠ correlation ≠ coincidence
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9593
Posted: 02:42am 30 Mar 2015
Copy link to clipboard 
Print this post

Okey dokey.

A single-line DO/LOOP should do it for you.

Lets assume you are putting your camera trigger output on pin2 of the MM chip:

Do:Loop until Pin(2)=1 - This will sit there and wait till pin2 goes high

On the very next line, you put the code you want to execute once the MM has detected the camera trip signal.

A full example might look something like this:


SetPin 2,DIN,PULLDOWN 'Configure input pin, and use internal pulldown to make it low
SetPin 3,DOUT:pin(3)=0 'Configure output pin, and set it low for now

Do:Loop until pin(2)=1 'Go around and around until pin3 goes high

Pin(3)=1 'Set pin3 high to trip the relay
Pause 1000
Pin(3)=0 'Set pin3 low to drop out relay


This is but an example....

EDIT: Corrected the comments for the PULLDOWN line in the code example above.Edited by Grogster 2015-03-31
Smoke makes things work. When the smoke gets out, it stops!
 
Benzol
Regular Member

Joined: 07/01/2015
Location: Australia
Posts: 64
Posted: 02:56am 30 Mar 2015
Copy link to clipboard 
Print this post

Thanks Michael. I haven't been using the CNTRL-C, just thinking if the program had finished it wasn't required.
Grogster, that's great. i was trying a resistor to pulldown the input but that simplfies everything. Also setting the DOUT low to start. i will start again and let you know the result.
 
Benzol
Regular Member

Joined: 07/01/2015
Location: Australia
Posts: 64
Posted: 12:44am 12 Apr 2015
Copy link to clipboard 
Print this post

Hi All
I'm putting together the hardware (built on Veroboard) but programming skills elude me. i found it easier to analyse satellite traffic.
I need to run a motor for a short time, stop the motor again for a short time then trigger a camera. Then loop, motor, camera, motor camera. Each part of code is just like the "flash the LED" code but I don't know how to tie it all together.

setpin 2, DIN, pulldown 'start switch
setpin 16, DOUT 'motor via relay
setpin 15, dout 'camera trigger via relay

do
while pin(2)=1 'start switch on
pin(16) = 1 'drive motor to move camera
pause 100
pin(16) = 0 'stop motor
Pause 200 '*this is where i need to trigger the camera*!
loop

do 'camera trigger This bit has to start 200mS after Pin 16 goes high
pin (15) = 1
pause 100
pin (15) = 0
pause 100
loop

Times here are just a test case, trial and error will give me the final figures. I just have to make sure the duty cycle for motor and camera are exactly the same.

i hate to ask, and I hope i'm not abusing the intent of this forum but some people are natural programmers, I'm not one of them.

thank you
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2933
Posted: 01:45am 12 Apr 2015
Copy link to clipboard 
Print this post

Hi David,

Couple of things - the 'new' syntax for 'while' is DO WHILE with a LOOP at the end (old syntax needed a WEND at the end)

Also a bit confused by "do 'camera trigger This bit has to start 200mS after Pin 16 goes high" where in the first DO/|LOOP you have you are triggering it after Pin16 goes low?

Anyway, try the following (assumes start switch is a changeover type (rather than a push button start)):


setpin 2, DIN, pulldown 'start switch
setpin 16, DOUT 'motor via relay
setpin 15, DOUT 'camera trigger via relay

DO
IF PIN(2)=1 THEN 'check start switch is on
PIN(16)=1 'switch motor relay ON
PAUSE 100 'delay a bit
PIN(16)=0 'switch motor relay OFF
TrigCam 'call a subroutine to trigger the camera
ELSE
'here you can do anything that needs doing when the start switch isn't 'on'

ENDIF
'here you can do other stuff (whether switch is on or off) before repeating the loop

LOOP

SUB TrigCam
PAUSE 200 'the 200mS delay you require
PIN(15)=1 'switch camera relay ON
PAUSE 100 'delay a bit
PIN(15)=0 'switch camera relay OFF
END SUB



Hope this gives you something to go with . . . .

WW
 
Benzol
Regular Member

Joined: 07/01/2015
Location: Australia
Posts: 64
Posted: 02:39am 12 Apr 2015
Copy link to clipboard 
Print this post

Thanks WW. when i see it like that it makes sense. Start switch is a changeover. The "do 'camera trigger This bit has to start 200mS after Pin 16 goes high" was my way of saying that the camera has to be triggered roughly in the middle of the motor off period. ie, 100mS for the camera move then 100mS is the middle of the motor off period. Timing can be, and probably will be changed depending on the time lapse movies goes. it's the duty cycles that are the important bits so the motor and camera don't get out of synch with the camera triggering during the motor movement.
Thanks again. I will test it out on a breadboard with some LEDs to simulate the relays.
db
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025