Any ideas on how best to achieve this idea? Logic lists?

I have a scenario where I want an input high/low to make output pins do high/low transitions according to set lists, for example like this "LLHHLHLHLHLLHLHL" or "LHHLHHHLL" so the lists of high/low and the number of high/low events will vary according to the list selected. The input pin on each high will advance through the list, so in other words a low on the input does nothing, for example the input is "HLHLHLHLHLHLHLHL" the output might be "HHLLHHLH"

Now in addition the high on the outputs will need to be a set duration lets say 10ms then go low, and also I want to have multiple output pins each with their own list, for example

Output 1 "LHLHHLHL"
Output 2 "LLLLHHLHHLHL"
Output 3 "LHLHLLLHLHLHLHLH"

At each completion of 1 pass through the list they would loop around back to the first position of the selected list, I plan on using a pot to select via readadc which list for each output. Probably will use a 20M2 eventually but will start with an 08M2 to get the initial concept working with just a single output.

I'm pretty sure this will be possible but as I am new to all this the terminology and structuring is a bit of a struggle, I'm guessing that I will need to use gosub or case but not sure how to tie it all together, I apologise if my use of terms is not correct but hopefully someone will know what I mean and put me on the right path.

Moderators - feel free to correct the post title with correct description if mine is wrong. Thanks.
 

grim_reaper

Senior Member
Just to clarify; are you saying you want the output switch to the next state in the pre-defined output (pattern/list) when the corresponding input receives a rising edge (i.e. only when it transitions from low to high)?
 

hippy

Technical Support
Staff member
Putting aside clearing outputs some time after they have been on for now you could do it as below -

Code:
Do
  If pinC.1 <> bit0 Then
    bit0 = bit0 ^ 1
    If bit0 = 1 Then
      LookUp b10, ( "LHLHHLHL" ), b11
      If b11 = "H" Then
        High C.2
      Else
        Low C.2
      End If
      b10 = b10 + 1 // 8
    End If
  End If
Loop
Basically waiting for an input to go high, deciding what to do from a list, updating which part of the list to use next time the pin goes high.

In this case activating input C.1 will cycle output C.2 according to the list in the LOOKUP.

Take a look at other projects for lighthouse map projects on the forum for inspiration because this is quite similar.
 
Just to clarify; are you saying you want the output switch to the next state in the pre-defined output (pattern/list) when the corresponding input receives a rising edge (i.e. only when it transitions from low to high)?
Yes exactly that - only you said it more succinctly :)
 

premelec

Senior Member
A possible simple way to do this is consider each sequence as a binary number or 16 bit word then 0 is low and 1 is high and then shift out the 0 and 1 values in a loop for the selected sequence either choosing the bit0-bit15 values or shifting by multiplying or dividing by 2 to change the value in a particular bit#...
 
Top