![]() |
Forum Index : Microcontroller and PC projects : Help with mm Basic
Author | Message | ||||
Benzol Regular Member ![]() Joined: 07/01/2015 Location: AustraliaPosts: 64 |
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 ZealandPosts: 9593 |
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? Smoke makes things work. When the smoke gets out, it stops! |
||||
Benzol Regular Member ![]() Joined: 07/01/2015 Location: AustraliaPosts: 64 |
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: GermanyPosts: 1576 |
Autorun Please read page 10 of Geoffs user manual for Micromite MkII. I can't better say that! ![]() Regards Michael causality ≠ correlation ≠ coincidence |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9593 |
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. Smoke makes things work. When the smoke gets out, it stops! |
||||
Benzol Regular Member ![]() Joined: 07/01/2015 Location: AustraliaPosts: 64 |
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: AustraliaPosts: 64 |
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 KingdomPosts: 2933 |
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: AustraliaPosts: 64 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |