Some code help please.

SteveD

Member
Hi guys,
I am totally new to this and have taken on a water drop controller and helped by bfgstew. Thanks m8.
I think I've done his head in enough now with little questions and ideas I had so have to ask here as this is my final step to having my controller working perfectly.

I'm out of memory on my 18M2 and need to cut the code down.
Now, I know nothing of starting and writing code, but have totally managed to fumble my way through the basic code Stewart sent me and added a lot of extras into that. It may, to you guys who know code, seem like a long winded burble, but it works so that will do for me.

What I am looking to do is add fine tune options into my code.
At the moment, what I have is a separate adjustment menu for each drop and interval, so 4 menus there, and one for each of camera delay and flash lag, 6 in total. If I go to adjust a value, I can then go to a menu to adjust that value, BUT, due to me having to have all these sub menus, and the lack of room thereof, I can't adjust them in both normal and bulb modes. Only one. Shame that.
I need a menu that will allow me to adjust whichever value i want changed, then go back to either the bulb or norm modes, where I sent the command from.

So, I am shooting in bulb mode, needing to adjust flashdelay (w7) I press my key to adjust this value, send it to the menu then it goes back to bulb mode and runs the program again with my adjusted value.

I want this option in normal mode too but I can only add another menu for that option with a goto runnorm after it. Can this be done in one menu?

I will post the code I have put together and hope there is a way to put them all together into a single menu.

Does anyone know how I can sort this as I have nearly gone bald trying to work it out.

Cheers.

Steve
 
Last edited:

SteveD

Member
Code:
d1plus:                                                                                                            ; allows drop 1 size fine tuning adding 1,5 or 10ms, 
            gosub GKP
		if key_value = 1 then let w2 = w2+1
		endif
		if key_value = 2 then let w2 = w2+5
		endif
		if key_value = 3 then let w2 = w2+10
		endif
		if key_value = 4 then let w2 = w2-1
		endif
		if key_value = 5 then let w2 = w2-5
		endif
            if key_value = 6 then let w2 = w2-20
            endif
            pause 30          
            serout B.7,N2400,(254,135,#w2)                                      
            pause 30
            goto runbulb
            
            
i1plus:                                                                                                            ; allows interval time fine tuning adding 1,5 or 10ms,
            gosub GKP
            if key_value = 1 then let w3 = w3+1
		endif
		if key_value = 2 then let w3 = w3+5
		endif
		if key_value = 3 then let w3 = w3+10
		endif 
		if key_value = 4 then let w3 = w3-1
		endif
		if key_value = 5 then let w3 = w3-5
		endif
		if key_value = 6 then let w3 = w3-10
		endif                                              
            serout B.7,N2400,(254,194,#w3)
            pause 30
            goto runbulb
            

d2plus:                                                                                                            ; allows drop 2 size fine tuning adding 1,5 or 10ms,
            gosub GKP
		if key_value = 12 then let w4 = w4+5
		endif            
		if key_value = 10 then let w4 = w4-5
		endif
            serout B.7,N2400,(254,139,#w4)                                       
            pause 30
           goto runbulb
            
            
adjustcd:                                                                                                       ; allows camera delay fine tuning adding 1,5 or 10ms,
            gosub GKP
		if key_value = 1 then let w8 = w8+1
		endif
		if key_value = 2 then let w8 = w8+5
		endif
		if key_value = 3 then let w8 = w8+10
		endif
		if key_value = 4 then let w8 = w8-1 
		endif             
            if key_value = 5 then let w8 = w8-5
            endif
            if key_value = 6 then let w8 = w8-10
            endif
            if key_value = 12 then let w8 = w8+20
		endif 
		if key_value = 10 then let w8 = w8-20
		endif
		serout B.7,N2400,(254,205,#w8) 
            pause 30
            goto runnorm


adjustfl:                                                                                                       ; allows flash lag fine tuning adding 1,5 or 10ms,
            gosub GKP
            if key_value = 1 then let w7 = w7+1
		endif
		if key_value = 2 then let w7 = w7+5
		endif
		if key_value = 3 then let w7 = w7+10
		endif
		if key_value = 4 then let w7 = w7-1
		endif
		if key_value = 5 then let w7 = w7-5
		endif
		if key_value = 6 then let w7 = w7-10
		endif           
		if key_value = 12 then let w7 = w7+20
		endif 
		if key_value = 10 then let w7 = w7-20
		endif 
		pause 30
            serout B.7,N2400,(254,205,#w7) 
            pause 30
            goto runbulb
 

SteveD

Member
The above code shows the wee menus I have to use for adjustments. I can do the adjustments no problem in bulb mode as the menu sends me back to running the program again. I need this in a single menu for each drop/pause and the ability to go back to the correct mode I have already chosen, preferably without having to press keys to select that option, ie # for norm mode, * for bulb mode. I've done that before, but would much rather just change the value, press my enter button and it automatically go back to the program.
Possible?

Steve.
 

SteveD

Member
Below is an instruction I wrote on the procedure of this code I have managed to get together.
This works fine here as I only have a max of 2 drops in the code. I had managed to get 3 drops in there, before I had to start using all these sub menus.

Turn the power on and you are shown the welcome screen.

" Serial OLED " ;change these to any values you want.
" www.picaxe.com "

Press any key to continue.


"*VALVE*" ;opens the valve
"1 DROPS 2" ;pick drop amount

1 goes to one drop menu
2 goes to two drop menu
* opens the valve



Setting up. Press * to open the valve and draw liquid through.


"VALVE OPEN" ;valve is constant open until # is pressed.



Press # to close valve.

"VALVE CLOSED"


Either press * to open the valve again or press 0 for a single drop for focusing. These steps can be done as many times as required. You can also select 1 or 2 drops.
1 goes to one drop menu
2 goes to two drop menu
0 advances a single drop for focusing
* opens the valve again




Set up done, ready for drops. The process is the same for either one or two drops. This is for two drops at 50ms and an interval of 80ms and flash lag at 300ms.



Press 2 for two drop menu.
"TWO DROPS"

"Drop One: 50 ms" ; the drop size is show for each drop in milliseconds.

Press # to continue.


"Interval: 80 ms" ;size of interval between drops in milliseconds.


Press # to continue.


"Drop Two: 50 ms" ; size of second drop in milliseconds.


Press # to continue.

"* FOR NORM" ;this mode is without flash option. Here a wireless trigger is needed unless camera has a pc sync port.
"# FOR BULB" ; uses bulb mode on camera and a flash option.


The following procedure is the same for both BULB and NORM modes, the difference being is that Camera Delay is there to delay the camera firing to compensate for the height of the drop, Flash lag is
the time after the camera shutter opening the flash is fired. This is for a darker room and uses longer exposure times.


This step is for BULB:

Press # to go to BULB option.


"DROPS: 50 50"
"I:80 FL:0"


Enter a value for flash lag ...300


"DROPS: 50 50"
"I:80 FL:300"


Press # to run these settings.




TICK TICK SPLASH!!!




"DROPS: 50 50"
"I:80 FL:300"


Here you can press either:

# to run the settings again, as many times as required;
0 to go back to the start, open/close valve, pick drop amount and begin from zero values;
5 swaps over to NORM mode and cam delay menu;
Fine tunes the ran settings by adding or subtracting either 1, 5 or 10 milliseconds from each drop, interval and flash lag (Camera delay in NORM).


Fine Tuning:
Press 1 to alter drop 1, then either 1 for +1ms, 2 for +5ms, 3 for +10ms or 4 for -1ms, 5 for -5ms, 6 for -10ms
Press 2 to alter interval, then either 1 for +1ms, 2 for +5ms, 3 for +10ms, 8 for +20ms or 4 for -1ms, 5 for -5ms, 6 for -10ms, 0 for -20ms
Press 3 to alter drop 2, then either 1 for +1ms, 2 for +5ms, 3 for +10ms, 8 for +20ms or 4 for -1ms, 5 for -5ms, 6 for -10ms, 0 for -20ms
Press 4 to alter Flash Lag, then either 1 for +1ms, 2 for +5ms, 3 for +10ms, 8 for +20ms or 4 for -1ms, 5 for -5ms, 6 for -10ms, 0 for -20ms
Press # to set Flash lag to zero and change the value by a larger or smaller value greater than 20ms.
If only a 2 digit value is chosen for camdelay or flash lag, Press # twice to run.
It is now just a case of toying with the settings to get the desired splash formations.
 
Last edited:

SteveD

Member
I've given as much info as I can for now on what I have and what I want to do. Hopefully someone will know what to do.

Cheers

Steve.
 

vttom

Senior Member
You have a snippet of code which is repeated a lot. You can make that code reusable by putting it inside a subroutine and reserving a variable (I used w1) to "pass" a value in and out:

Code:
d1plus: ; allows drop 1 size fine tuning adding 1,5 or 10ms, 
  gosub GKP

  if key_value = 6 then key_value = 10
  endif

  w1 = w2
  gosub adj_w1
  w2 = w1

  pause 30          
  serout B.7,N2400,(254,135,#w2)                                      
  pause 30
  goto runbulb
  
i1plus: ; allows interval time fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w3
  gosub adj_w1
  w3 = w1

  serout B.7,N2400,(254,194,#w3)
  pause 30
  goto runbulb

d2plus: ; allows drop 2 size fine tuning adding 1,5 or 10ms,
  gosub GKP

  if key_value = 12 then let w4 = w4+5 : endif            
  if key_value = 10 then let w4 = w4-5 : endif
  serout B.7,N2400,(254,139,#w4)                                       
  pause 30
  goto runbulb

adjustcd: ; allows camera delay fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w8
  gosub adj_w1
  w8 = w1

  serout B.7,N2400,(254,205,#w8) 
  pause 30
  goto runnorm

adjustfl: ; allows flash lag fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w7
  gosub adj_w1
  w7 = w1

  pause 30
  serout B.7,N2400,(254,205,#w7) 
  pause 30
  goto runbulb

adj_w1:
  if key_value =  1 then let w1 = w1+ 1 : endif
  if key_value =  2 then let w1 = w1+ 5 : endif
  if key_value =  3 then let w1 = w1+10 : endif
  if key_value =  4 then let w1 = w1- 1 : endif
  if key_value =  5 then let w1 = w1- 5 : endif
  if key_value =  6 then let w1 = w1-10 : endif                                              
  if key_value = 10 then let w1 = w1-20 : endif
  if key_value = 12 then let w1 = w1+20 : endif
  return
 

SteveD

Member
Thanks Tom, that has done me a treat now. I think I may even manage to get this to work in both modes with the room that saved. I'll keep working on that.

Steve.


You have a snippet of code which is repeated a lot. You can make that code reusable by putting it inside a subroutine and reserving a variable (I used w1) to "pass" a value in and out:

Code:
d1plus: ; allows drop 1 size fine tuning adding 1,5 or 10ms, 
  gosub GKP

  if key_value = 6 then key_value = 10
  endif

  w1 = w2
  gosub adj_w1
  w2 = w1

  pause 30          
  serout B.7,N2400,(254,135,#w2)                                      
  pause 30
  goto runbulb
  
i1plus: ; allows interval time fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w3
  gosub adj_w1
  w3 = w1

  serout B.7,N2400,(254,194,#w3)
  pause 30
  goto runbulb

d2plus: ; allows drop 2 size fine tuning adding 1,5 or 10ms,
  gosub GKP

  if key_value = 12 then let w4 = w4+5 : endif            
  if key_value = 10 then let w4 = w4-5 : endif
  serout B.7,N2400,(254,139,#w4)                                       
  pause 30
  goto runbulb

adjustcd: ; allows camera delay fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w8
  gosub adj_w1
  w8 = w1

  serout B.7,N2400,(254,205,#w8) 
  pause 30
  goto runnorm

adjustfl: ; allows flash lag fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w7
  gosub adj_w1
  w7 = w1

  pause 30
  serout B.7,N2400,(254,205,#w7) 
  pause 30
  goto runbulb

adj_w1:
  if key_value =  1 then let w1 = w1+ 1 : endif
  if key_value =  2 then let w1 = w1+ 5 : endif
  if key_value =  3 then let w1 = w1+10 : endif
  if key_value =  4 then let w1 = w1- 1 : endif
  if key_value =  5 then let w1 = w1- 5 : endif
  if key_value =  6 then let w1 = w1-10 : endif                                              
  if key_value = 10 then let w1 = w1-20 : endif
  if key_value = 12 then let w1 = w1+20 : endif
  return
 

SteveD

Member
That has worked a treat Tom. Thank you very much for that. Ran out of room again though. Trying to add same options to interval 2 in norm mode (I fitted it into bulb mode already) and drop 3 in both modes. 98% there now, but I just can't see a way of getting those extra bytes back for them to be written in.
 

hippy

Ex-Staff (retired)
You could perhaps replace the list of ...

if key_value = 1 then let w1 = w1+ 1 : endif

With ...

LOOKUP key_value, ( ... ), wTmp
w1 = w1 + wTmp

Not sure if that would be shorter or not. Or use EEPROM and READ to achieve the same.
 

SteveD

Member
Thanks Hippy.
I have been lost trying this really, I have a low concentration thing going on with my MS so find it hard to study manuals etc to learn this stuff, but I am trying.
The code I received from bfgstew was a basic 2 drop code to get me started, reading that code, I have managed to tinker around a lot and sort of learn how that runs, and with some pointers from himself and above from vttom and now yourself, this is nearly there.
This eeprom thing has me baffled. I have this controller using an 18M2 which is now full. There is also one on 16x2 oled module. Am I getting confused that you can save messages from my main program to the eeprom on the slave and link to that from the main program? Or is it just the eeprom on my main chip I save to? Meanwhile I'll go read up on how to operate the code you have suggested to me.
Thanks again.
You could perhaps replace the list of ...

if key_value = 1 then let w1 = w1+ 1 : endif

With ...

LOOKUP key_value, ( ... ), wTmp
w1 = w1 + wTmp

Not sure if that would be shorter or not. Or use EEPROM and READ to achieve the same.
 

westaust55

Moderator
@Steve,

First a question, you seem to be using word variables throughout? Are you expecting all values to be > 255 at some time or another? If not then byte variable would be an option.

I had a though similar to hippy with the use of the LOOKUP command.
Keep in mind that the PICAXE cannot handle negative numbers, so when you are needing a negative offset to reduce a value, in the statement:
LOOKUP key_value, ( ... ), wTmp
the part in brackets might be
(1,5,10,20,255,250,245,235) where a byte variable is the result, or
(1,5,10,20,35535,35530,35524,35514) where a word variable is the result

those last 4 values in each represent -1, -5, -10, -20 respectively.
 

SteveD

Member
Hi westaust55. Now that is the sort of talk that means nothing to me at this point in time. I haven't gotten to reading about what you mention.
I can't even answer your question as I don't understand what you say. Sorry.
I will get there. I struggle with reading manuals, tend to look for what I need at that time rather than go through it all, otherwise, by the time I get to what I need to do, I've forgotten everything.
Part of the confusion symptom of my MS.
What I am looking to do is get my code size down somehow to leave room to add a sound trigger at some point, or I am trying to add a time lapse option just now, but need memory space to get it in.


Steve.
@Steve,

First a question, you seem to be using word variables throughout? Are you expecting all values to be > 255 at some time or another? If not then byte variable would be an option.

I had a though similar to hippy with the use of the LOOKUP command.
Keep in mind that the PICAXE cannot handle negative numbers, so when you are needing a negative offset to reduce a value, in the statement:
LOOKUP key_value, ( ... ), wTmp
the part in brackets might be
(1,5,10,20,255,250,245,235) where a byte variable is the result, or
(1,5,10,20,35535,35530,35524,35514) where a word variable is the result

those last 4 values in each represent -1, -5, -10, -20 respectively.
 

bfgstew

Senior Member
Steve, not had a great deal of time to read through your code fully, but a quick scan shows a lot of memory is used up using repeated routines and the sections for fine tuning do take up a lot of space, my task will be to take those out and make the fine tuning a simpler routine, also you repeatedly use sertxd for the same display outputs, this can be reduced but will take a bit of doing, but it can be done. Some of the screen displays could be saved onto the OLED chips EEPROM to save a wee bit of room as well.
To add a sound trigger or time lapse onto this would be nigh on impossible, there is just not enough space, unless you go up to the 28X2 or 40X2.................just a thought!
 

vttom

Senior Member
Will a select/case take up less room than a bunch of if/then clauses? If so, then the common subroutine becomes:

Code:
adj_w1:
  select case key_value
  case  1 w1 = w1+ 1
  case  2 w1 = w1+ 5
  case  3 w1 = w1+10
  case  4 w1 = w1- 1
  case  5 w1 = w1- 5
  case  6 w1 = w1-10
  case 10 w1 = w1-20
  case 12 w1 = w1+20
  endselect
  return
 

vttom

Senior Member
Also, if you can spare a byte variable (represented by XXX below), you can use that to pass the middle value used by the serout command and sweep that into the common subroutine as well:

Code:
d1plus: ; allows drop 1 size fine tuning adding 1,5 or 10ms, 
  gosub GKP

  if key_value = 6 then key_value = 10
  endif

  w1 = w2
  XXX=135
  gosub adj_w1
  w2 = w1
  goto runbulb
  
i1plus: ; allows interval time fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w3
  XXX=194
  gosub adj_w1
  w3 = w1
  goto runbulb

d2plus: ; allows drop 2 size fine tuning adding 1,5 or 10ms,
  gosub GKP

  if key_value = 12 then let w4 = w4+5 : endif            
  if key_value = 10 then let w4 = w4-5 : endif
  serout B.7,N2400,(254,139,#w4)                                       
  pause 30
  goto runbulb

adjustcd: ; allows camera delay fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w8
  XXX=205
  gosub adj_w1
  w8 = w1
  goto runnorm

adjustfl: ; allows flash lag fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w7
  XXX=205
  gosub adj_w1
  w7 = w1
  goto runbulb

adj_w1:
  select case key_value
   case  1 w1 = w1+ 1
   case  2 w1 = w1+ 5
   case  3 w1 = w1+10
   case  4 w1 = w1- 1
   case  5 w1 = w1- 5
   case  6 w1 = w1-10
   case 10 w1 = w1-20
   case 12 w1 = w1+20
  endselect
  pause 30
  serout B.7,N2400,(254,XXX,#w7) 
  pause 30
  return
 

vttom

Senior Member
One more thing.... If you're willing to tweak how the key_value works for d1plus, you can sweep the "gosub GKP" inside "adj_w1" as well.
 

SteveD

Member
Thanks for this guys. I'm not at home for a day or two. My bro is real sick and i have mived into my mums for this few days. i need to be here with everyone. Il'll give this a go in a day or two when i go back home and let you know how it goes. Oh, i got the time-lapse thing kinda going...i get it to loop and add 2ms like i want it to, but i cant suss out how to get the loop to end and go back to my flash lag input menu. I added what i thought, several ways, but i can't get it out of there. I'll have a go when i get home into my pc. Thanks again to everyone, and again to you Stewart, i was really trying to give you a break from me there. :) you've done so much ready. Talk shortly guys. Steve.
 

SteveD

Member
Hi Tom, I tried this bit of code out and I got it working, I now have the ability to tune all 3 drops in both modes. Memory full again now.
I used it without the line if keY_value = 6 then key_value = 10 as it took me over the memory limit, but it works fine without it.
That will keep me going for now and I will see how it goes after tomorrow. I'll explain why I have not got straight to work on it all after your helping me once tomorrow has come and gone. Bfgstew will have an idea why. Thanks again.
Steve.
.
You have a snippet of code which is repeated a lot. You can make that code reusable by putting it inside a subroutine and reserving a variable (I used w1) to "pass" a value in and out:

Code:
d1plus: ; allows drop 1 size fine tuning adding 1,5 or 10ms, 
  gosub GKP

  if key_value = 6 then key_value = 10
  endif

  w1 = w2
  gosub adj_w1
  w2 = w1

  pause 30          
  serout B.7,N2400,(254,135,#w2)                                      
  pause 30
  goto runbulb
  
i1plus: ; allows interval time fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w3
  gosub adj_w1
  w3 = w1

  serout B.7,N2400,(254,194,#w3)
  pause 30
  goto runbulb

d2plus: ; allows drop 2 size fine tuning adding 1,5 or 10ms,
  gosub GKP

  if key_value = 12 then let w4 = w4+5 : endif            
  if key_value = 10 then let w4 = w4-5 : endif
  serout B.7,N2400,(254,139,#w4)                                       
  pause 30
  goto runbulb

adjustcd: ; allows camera delay fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w8
  gosub adj_w1
  w8 = w1

  serout B.7,N2400,(254,205,#w8) 
  pause 30
  goto runnorm

adjustfl: ; allows flash lag fine tuning adding 1,5 or 10ms,
  gosub GKP

  w1 = w7
  gosub adj_w1
  w7 = w1

  pause 30
  serout B.7,N2400,(254,205,#w7) 
  pause 30
  goto runbulb

adj_w1:
  if key_value =  1 then let w1 = w1+ 1 : endif
  if key_value =  2 then let w1 = w1+ 5 : endif
  if key_value =  3 then let w1 = w1+10 : endif
  if key_value =  4 then let w1 = w1- 1 : endif
  if key_value =  5 then let w1 = w1- 5 : endif
  if key_value =  6 then let w1 = w1-10 : endif                                              
  if key_value = 10 then let w1 = w1-20 : endif
  if key_value = 12 then let w1 = w1+20 : endif
  return
 

SteveD

Member
Used this one too Tom, it uses same amount of memory as the previous one.

Cheers.
Will a select/case take up less room than a bunch of if/then clauses? If so, then the common subroutine becomes:

Code:
adj_w1:
  select case key_value
  case  1 w1 = w1+ 1
  case  2 w1 = w1+ 5
  case  3 w1 = w1+10
  case  4 w1 = w1- 1
  case  5 w1 = w1- 5
  case  6 w1 = w1-10
  case 10 w1 = w1-20
  case 12 w1 = w1+20
  endselect
  return
 

westaust55

Moderator
Try changing the adj_w1: subroutine to:
Code:
adj_w1:
  LOOKUP key_value, (0,1,5,10,$FFFF,$FFF[COLOR="#0000FF"]B[/COLOR],$FFF[COLOR="#0000FF"]6[/COLOR],0,0,0,$FFE[COLOR="#0000FF"]C[/COLOR],0,20), [COLOR="#FF0000"]key_value[/COLOR]
  w1 = w1+ [COLOR="#FF0000"]key_value[/COLOR] 
  RETURN
note that the above destroys the original value in the variable key_value
if the variable key_value is not defined as a word variable then you will need to designate a new word variable at the two locations where there is red text

From my quick check,
SELECT CASE uses 110 bytes
IF THEN uses 72 bytes
LOOKUP uses 27 bytes


EDIT: corrected the above LOOKUP example for future reference so the negative values are -1, -5, -10, -20
 
Last edited:

SteveD

Member
Here is the code I am now using in a few posts. This will let you see what I have and if I should just leave it as is now.
I am starting to get back to normal from today.
My brother was sick with cancer, passed on Saturday and we had his funeral yesterday.
This is the reason I never jumped onto working with your help guys. Sorry.

Code:
#Picaxe 18M2

#no_data

				;PIN ASSIGNEMENTS
symbol ROW2 = B.6
symbol ROW3 = B.5
symbol COL3 = pinB.4
symbol ROW4 = B.3
symbol COL1 = pinB.2 
symbol ROW1 = B.1
symbol COL2 = pinB.0
symbol CAMERA = C.2
symbol FLASH = C.1
symbol NORMLED = C.0
symbol BULBLED = C.7
symbol SOLENOID = C.6



				;VARIABLE LABELS
symbol key_pos = b0
symbol key_value = b1
symbol dropcount = w1
symbol dropsize1a = w2                     
symbol dropdelay1 = w3
symbol dropsize2a = w4
symbol dropdelay2 = w5
symbol dropsize3a = w6
symbol flashdelay = w7             		
symbol camdelay = w8

					

init:                                                                                                      
          do
          gosub GKP
          if  key_value =< 12 then goto start
          loop Until key_value =< 12
           
 
           
start:                ;STARTING POINT OF ROUTINE EVERYTHING IS RETURNED TO ZERO
let key_pos = 0
let key_value = 0
let dropsize1a = 0                     
let dropdelay1 = 0
let dropsize2a = 0                              		
let camdelay = 0
let dropcount = 0
let flashdelay = 0



mainmenu:                         ; menu option to open valve for setting up or cleaning or enter drops via keypad ,
            serout B.7,N2400,(254,1)                                                                        
		pause 30
		serout B.7,N2400,(254,128,"   * VALVE *     ")
            serout B.7,N2400,(254,192,"  DROPS 1 2 3    ")
		pause 30
		do
		gosub GKP
		if key_value = 10 then goto valve           ; valve opens instantly
		if key_value = 1 then goto onedrop          ; single drop sequence
		if key_value = 2 then goto twodrop          ; two drop sequence
		if key_value = 3 then goto threedrop        ; three drop sequence
		loop
            
          
valve:                           ; opens/closes valve during setup or flushing valve through during cleaning ,                                                   
		serout B.7,N2400,(254,1)                                                                         
		pause 30
		serout B.7,N2400,(254,128,"   VALVE OPEN   ")
            high SOLENOID
		gosub GKP
            if key_value = 10 then return
            endif
            low SOLENOID
            serout B.7,N2400,(254,128,"  VALVE CLOSED  ")
            pause 30
            do
            gosub GKP
            if key_value = 10 then goto valve          ; re-open the valve,
            if key_value = 0 then goto single          ; single drop advance for focusing,
            if key_value =< 9 then goto start          ; any key from 1 and 8 to go back to the begining to select dropamount or open valve,
            loop
		
		
single:
            serout B.7,N2400,(254,1)                                                                          
		pause 30
		serout B.7,N2400,(254,128,"  SINGLE DROP   ")
		pause 30
            high SOLENOID
            pause 40
            low SOLENOID
            pause 30
            do
            gosub GKP
            if key_value = 0 then goto single          ; advance another drop
		if key_value = 10 then goto valve          ; open valve
            if key_value =< 9 then goto start          ; any key from 1 and 8 to go back to the begining to select drop amount or open valve
            loop
		                                                         

d1tn:                     ; drop 1 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms, 
            gosub GKP
            w10 = w2
            gosub tuning
            w2 = w10        
            serout B.7,N2400,(254,135,#w2)                                      
            pause 30
            goto runnorm

 
d1tb:                     ; drop 1 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms, 
            gosub GKP
            w10 = w2
            gosub tuning
            w2 = w10
            serout B.7,N2400,(254,135,#w2)
            pause 30
            goto runbulb


i1tn:                     ; interval 1 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms, 
            gosub GKP
            w10 = w3
            gosub tuning
            w3 = w10
            serout B.7,N2400,(254,194,#w3)
            pause 30
            goto runnorm
            

i1tb:                    ; interval 1 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms, 
            gosub GKP
            w10 = w3
            gosub tuning
            w3 = w10
            serout B.7,N2400,(254,194,#w3)
            pause 30
            goto runbulb
  
  
d2tn:                    ; drop 2 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms,
            gosub GKP  
            w10 = w4
            gosub tuning
            w4 = w10
            serout B.7,N2400,(254,139,#w4)
            pause 30
            goto runnorm
            
d2tb:                    ; drop 2 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms,
            gosub GKP  
            w10 = w4
            gosub tuning
            w4 = w10
            serout B.7,N2400,(254,139,#w4)
            pause 30
            goto runbulb
                        
            
i2tn:                   ; interval 2 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms,
            gosub GKP
            w10 = w5
            gosub tuning
            w5 = w10
            serout B.7,N2400,(254,198,#w5)
            pause 30
            goto runnorm
            
            
i2tb:                   ; interval 2 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms,
            gosub GKP
            w10 = w5
            gosub tuning
            w5 = w10
            serout B.7,N2400,(254,198,#w5)
            pause 30
            goto runbulb
            
d3tn:                    ; drop 3 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms,
            gosub GKP  
            w10 = w6
            gosub tuning
            w6 = w10
            serout B.7,N2400,(254,142,#w6)
            pause 30
            goto runnorm
            
d3tb:                    ; drop 3 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms,
            gosub GKP  
            w10 = w6
            gosub tuning
            w6 = w10
            serout B.7,N2400,(254,142,#w6)
            pause 30
            goto runbulb
            
            
tcd:                       ; camera delay fine tuning by adding or subtracting 1,5,10 or 20ms,
            gosub GKP
            w10 = w8
            gosub tuning
            w8 = w10
            serout B.7,N2400,(254,205,#w8) 
            pause 30
            goto runnorm



tfl:                ; flash lag fine tuning by adding or subtracting 1,5,10 or 20ms,
            gosub GKP
            w10 = w7
            gosub tuning
            w7 = w10
            serout B.7,N2400,(254,205,#w7) 
            pause 30
            goto runbulb
 

SteveD

Member
Code:
tuning:                  ; fine tune menu adding or subtracting 1,5,10 or 20 milliseconds to origianl value,
            select case key_value
            case  1 w10 = w10+ 1                                       ; +1ms
            case  2 w10 = w10+ 5                                       ; +5ms
            case  3 w10 = w10+10                                       ; +10ms
            case  4 w10 = w10- 1                                       ; -1ms
            case  5 w10 = w10- 5                                       ; -5ms
            case  6 w10 = w10-10                                       ; -10ms
            case 10 w10 = w10-20                                       ; -20ms
            case 12 w10 = w10+20                                       ; +20ms
            endselect          
            if key_value = 8 then goto initcd                         ; clear and enter a new value for cam delay
            if key_value = 0 then goto initfl                         ; clear and enter a new value for flash lag
            return
                         
  			
onedrop:                  ; sets valve open/close times for 1 drop sequence,
	      serout B.7,N2400,(254,1)    
	            pause 30
			gosub drop1
	            pause 30
	      serout B.7,N2400,(254,1)                                                                            
	            pause 30
		serout B.7,N2400,(254,128,"  *  FOR NORM   ")                                                        
		serout B.7,N2400,(254,192,"  #  FOR BULB   ")                   
		      pause 30
		      do
		      gosub GKP
		if key_value = 10 then goto cam    
		if key_value = 12 then goto bulb
		loop until key_value => 10
						

twodrop:                 ;  sets valve open/close times for 2 drop sequence,
		serout B.7,N2400,(254,1)                                                                           
			pause 30
	      	gosub drop1
	      	pause 30
	      	gosub Interval1
	      	pause 30
	      	gosub drop2
	      	pause 30
	      serout B.7,N2400,(254,1)                                                                            
			pause 30
		serout B.7,N2400,(254,128,"  *  FOR NORM   ")                                                        
		serout B.7,N2400,(254,192,"  #  FOR BULB   ")                   
		      pause 30
		      do
		      gosub GKP
		if key_value = 10 then goto cam     
		if key_value = 12 then goto bulb
		loop until key_value => 10
            
                                                		
threedrop:                ; sets valve open/close times for 3 drop sequence. 
		serout B.7,N2400,(254,1)            
			pause 30
	      	gosub drop1
	      	pause 30
	      	gosub interval1
	      	pause 30
	      	gosub drop2
	      	pause 30
	      	gosub interval2
                  pause 30
                  gosub drop3
                  pause 30
		serout B.7,N2400,(254,128,"Press * for NORM")
		serout B.7,N2400,(254,192,"Press # for BULB")
		pause 30 
		do
		gosub GKP
		if key_value = 10 then goto cam
		if key_value = 12 then goto bulb
		loop until key_value => 10		
	      
	      				
initd1:

let key_pos = 0
let key_value = 0
let dropsize1a = 0              

drop1:			   ; sets the valve open time via keypad
	serout B.7,N2400,(254,1)
			pause 30
	serout B.7,N2400,(254,128,"Drop one:")
	           pause 30
		For b20 = 1 to 4				
  			Gosub GKP 
  			if key_value = 10 then goto initd1    ; press * to clear value and start again BEFORE pressing # to enter.
  			if key_value = 12 then return         ; press # to enter and move on to next stage,
  			endif	
  			w2 = w2 * 10 + b1
  			serout B.7,N2400,(254,139,#w2,254,142,"ms")
  			pause 30
  			next b20
 		Return


initi1:

let key_pos = 0
let key_value = 0                    
let dropdelay1 = 0
			 
interval1:			; sets the valve closed time via keypad
	   serout B.7,N2400,(254,1)
			  pause 30
	   serout B.7,N2400,(254,128,"Interval:")
	              pause 30
		   For b20 = 1 to 4				
  			  Gosub GKP
  			  if key_value = 10 then goto initi1    ; press * to clear value and start again BEFORE pressing # to enter.
  			  if key_value = 12 then return         ; press # to enter and move on to next stage,
  			  endif	 
  			  w3 = w3 * 10 + b1
  			  serout B.7,N2400,(254,139,#w3,254,142,"ms")
  			  pause 30
  			  next b20
 		  Return	
 		  
 		  	
initd2:

let key_pos = 0
let key_value = 0
let dropsize2a = 0 
	 
drop2:		        ; sets the valve open time via keypad
	serout B.7,N2400,(254,1)
			pause 30
	serout B.7,N2400,(254,128,"Drop two:")
	            pause 30
		For b20 = 1 to 4				
  			Gosub GKP
  			if key_value = 10 then goto initd2       ; press * to clear value and start again BEFORE pressing # to enter.
  			if key_value = 12 then return            ; press # to enter and move on to next stage,
  			endif	
  			w4 = w4 * 10 + b1
  			serout B.7,N2400,(254,139,#w4,254,142,"ms")
  			pause 30
  			next b20
 		Return
 	
 		
initi2:

let key_pos = 0
let key_value = 0
let dropdelay2 = 0

interval2:				; sets the valve closed time via keypad,
	serout B.7,N2400,(254,1)
			pause 50
	serout B.7,N2400,(254,128,"Interval:")
	            pause 30
		For b20 = 1 to 4				
  			Gosub GKP
  			if key_value = 10 then goto initi2       ; press * to clear value and start again BEFORE pressing # to enter.
  			if key_value = 12 then return            ; press # to enter and move on to next stage,
  			endif	 
  			w5 = w5 * 10 + b1
  			serout B.7,N2400,(254,138,#w5,"ms")
  			pause 30
  			next b20
 		Return


initd3:

let key_pos = 0
let key_value = 0
let dropsize3a = 0 
 		
drop3:				; sets the valve open time via keypad,
	serout B.7,N2400,(254,1)
			pause 50
	serout B.7,N2400,(254,128,"Drop three:")
	            pause 30
		For b20 = 1 to 4				
  			Gosub GKP
  			if key_value = 10 then goto initd3        ; press * to clear value and start again BEFORE pressing # to enter.
  			if key_value = 12 then return             ; press # to enter and move on to next stage,
  			endif	
  			w6 = w6 * 10 + b1
  			serout B.7,N2400,(254,140,#w6,"ms")
  			pause 30
  			next b20
 		Return
 

SteveD

Member
Code:
initcd:

let key_pos = 0
let key_value = 0
let camdelay = 0


cam:	                       ; sets the flash fire delay to compensate for valve height,
            serout B.7,N2400,(254,1)                                                                                                                                                ; clears screen ,                                                                           ; clears screen ,                                                                            ; clears screen ,   
			pause 30	
            serout B.7,N2400,(254,128,"DROPS:",254,135,#w2,254,139,#w4,254,142,#w6)                               
            serout B.7,N2400,(254,192,"I:",254,194,#w3,254,198,#w5,254,202,"CD:",254,205,#w8) 
                  pause 30
                  gosub cdelay
  			 pause 30
  			 do
  			 gosub GKP
  			 if key_value = 10 then goto initcd      ; press * to clear value and start again BEFORE pressing # to enter.
  		       if key_value = 12 then goto runnorm     ; press # to enter and move on to next stage,
 		loop
 		 
                 		
cdelay:
            For b20 = 1 to 3				
  			Gosub GKP
  			      if key_value = 10 then goto initcd 
  				if key_value = 12 then return
  			endif	
  			w8 = w8 * 10 + b1
  			serout B.7,N2400,(254,205,#w8)
  			pause 30
  			next b20
 		Return
 		
 		            
initfl:

let key_pos = 0
let key_value = 0
let flashdelay = 0

bulb:	                       ; sets the flash fire delay to compensate for valve height,
            serout B.7,N2400,(254,1)                                                                          
			pause 30
            serout B.7,N2400,(254,128,"DROPS:",254,135,#w2,254,139,#w4,254,142,#w6)                                       
            serout B.7,N2400,(254,192,"I:",254,194,#w3,254,198,#w5,254,202,"FL:",254,205,#w7)
                  pause 30
                  gosub flag
          	       do
          	       gosub GKP
  			      if key_value = 10 then goto initfl     ; press * to clear value and start again BEFORE pressing # to enter.
  				if key_value = 12 then goto runbulb    ; press # to enter and move on to next stage,
 		 loop
 		
                   						
				
flag:
		For b20 = 1 to 3				
  			Gosub GKP
  			      if key_value = 10 then goto initfl    ; press * to clear value and start again BEFORE pressing # to enter.
  				if key_value = 12 then return         ; press # to enter and move on to next stage,
  			endif	
  			w7 = w7 * 10 + b1
  			serout B.7,N2400,(254,205,#w7)
  			pause 30
  			next b20
 		Return
 		

runnorm:				;Run sequence
	high CAMERA
	pause 200
	low CAMERA
	pause 1000
	high SOLENOID
	pause dropsize1a
	low SOLENOID
	pause dropdelay1
	high SOLENOID
	pause dropsize2a
	low SOLENOID
	pause dropdelay2
	high SOLENOID
	pause dropsize3a
	low SOLENOID
	pause camdelay
	high NORMLED
	high CAMERA
	pause 100
	low CAMERA
	low NORMLED
	serout B.7,N2400,(254,1)
	            pause 30
	      serout B.7,N2400,(254,128,"DROPS:",254,135,#w2,254,139,#w4,254,142,#w6)                                      
            serout B.7,N2400,(254,192,"I:",254,194,#w3,254,198,#w5,254,202,"CD:",254,205,#w8)                        
		      pause 30
	do
	gosub GKP
        if key_value = 12 then goto runnorm    ; repeat sequence with current settings,
        if key_value = 0 then goto start       ; go back to the begining.valve or drops,
        if key_value = 1 then goto d1tn        ; fine tuning option for drop 1
        if key_value = 2 then goto i1tn        ; fine tuning option for interval 1,
        if key_value = 3 then goto d2tn        ; fine tuning option for drop 2,
        if key_value = 4 then goto i2tn        ; fine tuning option for interval 2,
        if key_value = 5 then goto d3tn        ; fine tuning option for drop 3,
        if key_value = 6 then goto tcd         ; fine tuning option for camera delay,
        loop
   
        	
RUNBULB:				;Run sequence
      high CAMERA
	pause 200
	low CAMERA
	pause 1000
	high NORMLED
	high CAMERA
	high SOLENOID
	pause dropsize1a
	low SOLENOID
	pause dropdelay1
	high SOLENOID
	pause dropsize2a
	low SOLENOID
	pause dropdelay2
	high SOLENOID
	pause dropsize3a
	low SOLENOID
	pause flashdelay
	high BULBLED
	high FLASH
	pause 100
	low FLASH
	low BULBLED
	low CAMERA
	low NORMLED
	serout B.7,N2400,(254,1)
	pause 30
	      serout B.7,N2400,(254,128,"DROPS:",254,135,#w2,254,139,#w4,254,142,#w6)                                     
            serout B.7,N2400,(254,192,"I:",254,194,#w3,254,198,#w5,254,202,"FL:",254,205,#w7)                        
		pause 30
	do
	gosub GKP
        if key_value = 12 then goto runbulb      ; repeat sequence with current settings,
        if key_value = 0 then goto start         ; go back to the begining.valve or drops,
        if key_value = 1 then goto d1tb          ; fine tuning option for drop 1
        if key_value = 2 then goto i1tb          ; fine tuning option for interval 1,
        if key_value = 3 then goto d2tb          ; fine tuning option for drop 2,
        if key_value = 4 then goto i2tb          ; fine tuning option for interval 2,
        if key_value = 5 then goto d3tb          ; fine tuning option for drop 3,
        if key_value = 6 then goto tfl           ; fine tuning option for camera delay,
        loop
        	
						      	
GKP:							;Keypad scan coding
 	 Do
    		Gosub GTKP			' Wait until no key pressed
  			Loop Until key_value = 0
 	 Do
   		 Gosub GTKP			' Wait until key pressed
  			Loop Until key_value <> 0
  			If key_value = 11 Then
    			key_value = 0
  		End If
  	Return		
GTKP:						;Keypad scan coding
		key_pos = 0
		key_value = 0
	 	High ROW1 : gosub ScanCol : low ROW1
	 	High ROW2 : gosub ScanCol : low ROW2
	 	High ROW3 : gosub ScanCol : low ROW3 
	 	High ROW4 : gosub ScanCol : low ROW4
	 	Return	 	
	 	ScanCol:
	 		if COL1 = 1 then : key_value = key_pos + 1 : endif
	 		if COL2 = 1 then : key_value = key_pos + 2 : endif
	 		if COL3 = 1 then : key_value = key_pos + 3 : endif
	 		key_pos = key_pos + 3   
   		return
 

SteveD

Member
This is the wee controller I constructed. And yes, there is a hole in the side, lol. My bad. Drilled wrong side of box. I may hook something into a socket there one of the days.
:)

1270624_10200850313274777_594752107_o.jpg
 

westaust55

Moderator
Code:
tuning:                  ; fine tune menu adding or subtracting 1,5,10 or 20 milliseconds to origianl value,
            select case key_value
            case  1 w10 = w10+ 1                                       ; +1ms
            case  2 w10 = w10+ 5                                       ; +5ms
            case  3 w10 = w10+10                                       ; +10ms
            case  4 w10 = w10- 1                                       ; -1ms
            case  5 w10 = w10- 5                                       ; -5ms
            case  6 w10 = w10-10                                       ; -10ms
            case 10 w10 = w10-20                                       ; -20ms
            case 12 w10 = w10+20                                       ; +20ms
            endselect          
            if key_value = 8 then goto initcd                         ; clear and enter a new value for cam delay
            if key_value = 0 then goto initfl                         ; clear and enter a new value for flash lag
            return

Sorry to hear about your brother. Condolences from down under.

With reference to your code above you might wish to go back and look at the alternative code I gave you to try at post 20.

If you want folks here to help you reduce overall code size so you can add more features, then I suggest that it may be better if you post your entire code thus far as a single file (even as a .bas file as save by the PE) rather than bits and pieces.

The physical side of you project looks quite neat.
 

SteveD

Member
Thank you for this advice m8.
I didn't know how to post the bas file here, so had to do it in bits as the forum won't let me post it all in one go.

I will have a go at the alt code you gave me and in this post should be link for the bas file.
Thanks again.

http://www.mediafire.com/?1mkrc5cx1tpb7bt

Sorry to hear about your brother. Condolences from down under.

With reference to your code above you might wish to go back and look at the alternative code I gave you to try at post 20.

If you want folks here to help you reduce overall code size so you can add more features, then I suggest that it may be better if you post your entire code thus far as a single file (even as a .bas file as save by the PE) rather than bits and pieces.

The physical side of you project looks quite neat.
 

westaust55

Moderator
Thank you for this advice m8.
I didn't know how to post the bas file here, so had to do it in bits as the forum won't let me post it all in one go.
To attach a file click on the Go Advanced button at the bottom right.
Then you have some extra tool bars at the top of the post window.
Click on the paperclip icon which will put you into file manager.
There you can browse for the desired file and upload the file.

Another hint:
If you use the Reply With Quote at bottom right try to remove al but the specific part you are responding to keeping the quote tags at the start and end.
Alternatively, use the Reply to Thread button at the bottom left and you can put the at symbol ( @ ) in front of name for person you are replying to.
This is advise that many can use so please don't take it as a critisism just a suggestion which can make reading down a thread cleaner and easier.
 
Last edited:

SteveD

Member
Hi m8,
I tried this code just, I need to learn about these numbers within this to make them work properly. My + numbers are fine, it is the - values I need to change.
the code does what it is meant to, apart from those values, but it doesn't save me any room I'm afraid. The - values add on or take away different values, depending on which drop/interval I am tuning. they are different.
Thanks for that though.

Try changing the adj_w1: subroutine to:
Code:
adj_w1:
  LOOKUP key_value, (0,1,5,10,$FFFF,$FFFA,$FFF5,0,0,0,$FFEB,0,20), [COLOR="#FF0000"]key_value[/COLOR]
  w1 = w1+ [COLOR="#FF0000"]key_value[/COLOR] 
  RETURN
 

AllyCat

Senior Member
Hi Steve,

It looks as if your current code is "oversize" (PE reports 2048 bytes even after a few deletions).

There are a lot of similar "modules" near the start so the code can probably be reduced by using another subroutine (and finding / creating a free variable), for example:

Code:
symbol curpos = b0		; choose / create a "free" variable to use here
GKPex:                               ; New Subroutine
         gosub GKP
         gosub tuning        
         serout B.7,N2400,(254,curpos,#w10)                                      
         pause 30
         return
d1tn:            
        curpos = 135
	w10 = w2
	gosub GKPex
 	w2 = w10
         goto runnorm 	
d1tb:                     ; drop 1 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms, 
	curpos = 135
         w10 = w2
         gosub GKPex
         w2 = w10
          goto runbulb
i1tn:                     ; interval 1 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms, 
	 curpos = 194
         w10 = w3
         gosub GKPex
          w3 = w10
          goto runnorm

;    .... etc.
The "pairs" of routines (...n and ...b) can probably be combined / reduced further.

Cheers, Alan.
 

bfgstew

Senior Member
Hi Steve, I have finally got my unit up and running, downloaded your code onto my unit and can now have a proper look at it.
Give me a day or two and hopefully can get it down to fit the 18M2 for you.

Stewart
 

SteveD

Member
@AllyCat
Thank you for that advice there. It has saved me some scrolling in the editor, but most importantly, saving me 22 bytes. Excellent. :)
 

SteveD

Member
Thanks Stewart.
I've got mine lowered by 22bytes thanks to @AllyCats suggested code.
Seeing as I don't know coding, this may well be a daft question...but is there a way to code this to make the program remember which menu it was in prior to tuning? i.e if I had chosen to use BULB, then instead of sending it into D1tb for drop 1 bulb, it could be in a shared menu there and automatically go to bulb if I was using BULb, or NORM if using that option ? This would half the number of those wee menus there yeah ?
Sorry if it does sound stoopid..

Steve.

Code:
GKPex:                               ; New Subroutine
         gosub GKP
         gosub tuning        
         serout B.7,N2400,(254,curpos,#w10)                                      
         pause 30
         return
         


d1tn:                     ; drop 1 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms, 
            curpos = 135
            w10 = w2
            gosub GKPex
            w2 = w10        
            goto runnorm

 
d1tb:                     ; drop 1 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms, 
            curpos = 135
            w10 = w2
            gosub GKPex
            w2 = w10
            goto runbulb


i1tn:                     ; interval 1 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms, 
            curpos = 135
            w10 = w3
            gosub GKPex
            w3 = w10
            goto runnorm
            

i1tb:                    ; interval 1 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms, 
            curpos = 194
            w10 = w3
            gosub GKPex
            w3 = w10
            goto runbulb
  
  
d2tn:                    ; drop 2 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms,
            curpos = 139  
            w10 = w4
            gosub GKPex
            w4 = w10
            goto runnorm
            
d2tb:                    ; drop 2 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms,
            curpos = 139  
            w10 = w4
            gosub GKPex
            w4 = w10
            goto runbulb
                        
            
i2tn:                   ; interval 2 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms,
            curpos = 198
            w10 = w5
            gosub GKPex
            w5 = w10
            goto runnorm
            
            
i2tb:                   ; interval 2 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms,
            curpos = 198
            w10 = w5
            gosub GKPex
            w5 = w10
            goto runbulb
            
d3tn:                    ; drop 3 size fine tuning in NORM mode adding or subtracting 1,5,10 or 20ms,
            curpos = 142
            w10 = w6
            gosub GKPex
            w6 = w10
            goto runnorm
            
d3tb:                    ; drop 3 size fine tuning in BULB mode adding or subtracting 1,5,10 or 20ms,
            curpos = 142
            w10 = w6
            gosub GKPex
            w6 = w10
            goto runbulb
            
            
tcd:                       ; camera delay fine tuning by adding or subtracting 1,5,10 or 20ms,
            curpos = 205
            w10 = w8
            gosub GKPex
            w8 = w10
            goto runnorm



tfl:                ; flash lag fine tuning by adding or subtracting 1,5,10 or 20ms,
            curpos = 205
            w10 = w7
            gosub GKPex
            w7 = w10
            goto runbulb
Hi Steve, I have finally got my unit up and running, downloaded your code onto my unit and can now have a proper look at it.
Give me a day or two and hopefully can get it down to fit the 18M2 for you.

Stewart
 

SteveD

Member
Ok. I got it down more by removing a lot of pauses that didn't need to be there by the look of it. I have added in 2 timelapse menus for both BULB and NORM. The problem I have now is, I can get the menu to loop for me in the steps I wanted, I just can't get it to come out of that loop for me and go to the start of the program again. Tried everything I know about so far. I have to turn the unit off to get out of it. I am trying to get it to take shots of the same drop size and pause, just adding on 2ms cam delay/flash lag onto each shot. I need to be able to stop that if I can't clear my bubbles from the dish/cup in time for the next shot. Any ideas ?
Code:
TLN:
            let w8 = w8+ 2
            serout B.7,N2400,(254,205,#w8)
            high CAMERA
	      pause 200
	      low CAMERA
	      pause 1000
      	high SOLENOID
        	pause dropsize1a
      	low SOLENOID
      	pause dropdelay1
      	high SOLENOID
      	pause dropsize2a
      	low SOLENOID
       	pause dropdelay2
      	high SOLENOID
      	pause dropsize3a
        	low SOLENOID
       	pause camdelay
      	high NORMLED
      	high CAMERA
       	pause 100
      	low CAMERA
       	low NORMLED
            pause 5000
            goto TLN
 

bfgstew

Senior Member
Steve, now I have had a tinker and the easiest way to reduce the code was to remove all the adjustment parts, you can still adjust the times as when it has completed its run, you can go back to the setting points, see the old values and change them or keep them, it does seem to work on mine.
Got it down to 1950 bytes.
Will have a look at the above in a bit.

Stewart

PS can't upload code until morning as at work!
 

bfgstew

Senior Member
Steve, instead of the goto TLN at the end, add

do
gosub GKP
loop until key_value = 12
goto TLN

OK you have to press # each time but at least you are in control and you can wait until the bubbles have dissapeared before you press it?
 

SteveD

Member
Ahh, stewart, that's worked fine. That will do me. Back to 2048 now, but that's all the tweaks I can think of on this.

Thanks again everyone for the help.
Stewart, what next ? lol. ;)
Steve, instead of the goto TLN at the end, add

do
gosub GKP
loop until key_value = 12
goto TLN

OK you have to press # each time but at least you are in control and you can wait until the bubbles have dissapeared before you press it?
 

bfgstew

Senior Member
Steve, I can't open the bas file on works PC, but we should be able to shoehorn it in with the amended code and you'll have 3 drops and your time lapse, as I said down to 1950 so should be plenty of room...........:p

Have had it running on my controller and it seems to work OK, will post it up in the morning when I get home after my shift.
 

SteveD

Member
That's her running now with up to 3 drops, all tuning settings +/- 1,5,10,20ms +2ms time lapse,
:)
Steve, I can't open the bas file on works PC, but we should be able to shoehorn it in with the amended code and you'll have 3 drops and your time lapse, as I said down to 1950 so should be plenty of room...........:p

Have had it running on my controller and it seems to work OK, will post it up in the morning when I get home after my shift.
 
Top