ZappBots wishes a warm welcome to everyone.

Especially our visitors from
Savage///Circuits and Parallax!!!


Please take a look our new forums, we hope you register and become an active user.

The ZappBots forums are being run on phpBB 3.1.4 software which is different then the vBulletin used on the Savage///Circuits and Parallax forums.
Therefore, things look and work a little different, especially creating posts and uploading images / attachments.


The important thing is we have a place toTalk, Learn and Showcase our projects.

Eye Activated Switch

This is the place to talk about Bio-Medical Electronics
User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

Re: Eye Activated Switch

Postby Electrons-R-Fun » Mon Jun 22, 2015 6:40 am

I've been working with some components, moving the ground electrode to different grounding locations, switching sides of + and - leads, and the locations of the eye electrodes to see if I can get a better signal. I've also been trying different things with the code to make the project more reliable.

I put the electrodes on me and got some really good results. I found moving the ground electrode to my finger was a really good place, and I changed the + and - electrode to the opposite sides and got even better wave forms to use. So I have a couple of choices, I can use to control false activation and get reliable activation of the code. 1). I can use a threshold system (easiest), 2). I can make sure the wave form has move passed the threshold over a certain amount of time, 3). I can measure the change from the normal wave form and if the change is the correct amount I can have it program perform some task.

I am currently using a threshold system and I was able to move my eyes around and look at different stuff without setting off the program, but Lisa might be different. No matter what... I'm pretty sure I will use the demo, Chris wrote for the encoder menu, to set the variables I will need to fine tune the device for Lisa.

I will post picture of the new waves tomorrow and maybe make a short video of me using the device to speak through the Dyna-Vox or/and the matrix grid. Too tired for all that now.

When you look at the pictures, you can see the dip in the voltage is a much larger change from the rise in the O-Scope graph making that change more desirable to use for Lisa's one switch input.

looking straight.jpg
wave form is much better now.
(852.45 KiB) Not downloaded yet
Looking striaght.jpg
old wave form, all over the place
(61.02 KiB) Not downloaded yet
Looking left, right, left again.jpg
You can see a definite change in the wave form
(823.65 KiB) Not downloaded yet
looking left, then right.jpg
a smooth wave form with two different eye movements visiable.
(957.46 KiB) Not downloaded yet

User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

Re: Eye Activated Switch

Postby Electrons-R-Fun » Wed Jun 24, 2015 2:21 pm

I'm going to try and write some code about polling a threshold value being over that threshold for a certain amount of time before I have the code actually enact any commands. My goal is to reduce false activation and put some extra reliability into the system so Lisa can look around with out setting off the code commands accidentally.

I have some ideas how to do this, but most of the time I'm a little off. If I get stuck, I mean when I get stuck, I'll post were I'm stuck and ask for some direction. But in the mean time I was able to use the Matrix Grid very reliably, move my eyes around without activating the code, but I need to get better batteries these are almost dead and caused me some grief for an hour or so the other day because the circuit was acting very funny, so a capacitor across Vin helped and changing the batteries also helped.

Jason

User avatar
Savage///Circuits
VIP
VIP
Posts: 404
Joined: Tue May 12, 2015 2:43 pm
Location: Palmyra, NY
Contact:

Re: Eye Activated Switch

Postby Savage///Circuits » Wed Jun 24, 2015 11:54 pm

Typically what I do is reset a counter to zero when the trigger is not in range. When it is I start incrementing the variable until a threshold is reached. If it is then you activate the prescribed routine. If it falls out again you reset the variable. I have covered this on the BS2 using passive or loop counters.
Image
I'm only responsible for what I say, not what you understand.

User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

Re: Eye Activated Switch

Postby Electrons-R-Fun » Thu Jun 25, 2015 3:03 pm

Hi Chris,

I was thinking along those lines... I also think...? the What's a MicroController Book (for the BS2) and Propeller Education Kit Book (for the Propeller) talk about Polling also.

I did try writing some code last night about incrementing the variable by a factor of time by 1 ms at a time and then using the conditional statement IF the variable was > 400 (so 400 ms) to start the process connected to that code. But the PST just showed the code got stuck counting the variable and just stayed there. I think I need a new cog to control the counting process so the code doesn't get stuck in the Repeat while ( threshold value is lower than set point).

Speaking of threshold set point. I am trying to figure out a way of figuring out what that threshold should be. The values are always different depending on a variety of things, likes sweat, battery power, location of EEG sensors. But I don't want to use the O-Scope every time. So I push a button and the PST displays 100 voltage samples, that were taken in 20 ms increments, and then I just go through the list and look for the group that has the lowest values, look for the lowest value and then set the threshold to a value 0.25 volts higher than the lowest sample I could find. I was wondering if there is a way for a piece of code to find the lowest value of the 100 samples for me, without assigning each of the 100 sample's there own variable?

Anyway, that's where I'm at currently.

Jason

User avatar
Savage///Circuits
VIP
VIP
Posts: 404
Joined: Tue May 12, 2015 2:43 pm
Location: Palmyra, NY
Contact:

Re: Eye Activated Switch

Postby Savage///Circuits » Thu Jun 25, 2015 4:22 pm

Not sure the polling thing is what I am talking about, but I haven't looked in the W.A.M. text to see what you're referring to. Another option is when the condition is met you can set a variable to the current counter value plus some offset. Then during the loop test for that value to have passed. I use a similar scheme as a timeout in certain loops so they don't get stuck there.

As for the 100 voltage sample. Not sure why you'd need that many but one option is to do a running average. The inherent issue there is that a sudden change in one sample can affect the overall average by 50% of the difference.
Image
I'm only responsible for what I say, not what you understand.

User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

Re: Eye Activated Switch

Postby Electrons-R-Fun » Fri Jun 26, 2015 2:24 pm

:D
As for the 100 voltage sample. Not sure why you'd need that many but one option is to do a running average. The inherent issue there is that a sudden change in one sample can affect the overall average by 50% of the difference.


Thanks for all the tips Chris,

The only way I know how to do a running sample is using the OBJECT for the ADC:

Code: Select all

PUB average(channel, n) : sample | c

'' Average n samples from an ADC channel (0..7)

  c := count
  repeat n
    repeat while c == count
    sample += ins.word[channel]
    c++
  sample /= n



I did try this Block, with a 500 sample rate, but it does not give me a lowest number to set the threshold when I ask Lisa to look to the right. The Average sampling code is great for giving me a value when a person is looking straight ahead and not trying to activate anything, the code was useful in obtaining a nice reference point I thought about using to make a window comparator, which would be used to trigger the IF statement.


I was going to answer why I sampled a 100 voltages. I know I have to approach projects from a simpler and different manor than all the pros would (meaning I do it differently) but I'm stuck doing it the way I think I can accomplish my goal with the knowledge I have :?: (wait,... what knowledge? I seem to have miss placed it again, I think it's on this desk somewhere :D )

So In my program I ask the user to get ready to look to the right (or left if you hook it up the other way) I give them a countdown and then the instructions ask them to look left. The problem is Lisa can't look left at command, I was sampling 50 sample's (so 1 second worth) but I was not able to get the lowest value set. When I increased it to a 100 samples (2 seconds) I was able to scroll through the values and find the low set pretty fast and the more important part was the PST did capture it. I guess, in some more effective/productive way I could use my Average in value and tell the program to repeat until it sees a value low enough to start capturing the values and that would give Lisa plenty of time to look and I would have to look through 100 values, (maybe 25) but of course.... I didn't think of that until right now. But I did get a chance to see the range the values go through and how fast they change without the O-scope :)

Ok the new battery holders are here for the 18650 battery's, so I'm going to hook them up.

Jason

User avatar
Savage///Circuits
VIP
VIP
Posts: 404
Joined: Tue May 12, 2015 2:43 pm
Location: Palmyra, NY
Contact:

Re: Eye Activated Switch

Postby Savage///Circuits » Sun Jun 28, 2015 12:25 am

You're learning from experimenting...would it surprise you to know that after all these years I have to do some empirical testing sometimes to figure things out that stump me? I was working on a test for BASIC Stamp Modules and thought I could rig up this clever test (see the link below).

https://twitter.com/savagecircuits/stat ... 5646696448

The problem was that the information I was getting wasn't right and I didn't figure it out until I went to modify the code for someone on the forums using a different model of BASIC Stamp. See the link to the Parallax forums:

http://forums.parallax.com/showthread.p ... ost1333364

I haven't had much time to mess with it since then, but I am still stumped as to why the variable delay numbers show up properly, but the delay doesn't seem to correspond to the values. It's driving me nuts! :oops:
Image
I'm only responsible for what I say, not what you understand.

User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

Re: Eye Activated Switch

Postby Electrons-R-Fun » Wed Jul 22, 2015 5:31 am

Been busy with Lisa being sick for a month, opening a Kung Fu San Soo school, getting my knee hurt in a Judo competition, and waiting for Florida Research Instruments to finally ship my order of reusable dry electrodes, so I can experiment with them too see if they will work or not.

I also need to write some more code and then give the whole thing a try again.

More later,

Jason

User avatar
Savage///Circuits
VIP
VIP
Posts: 404
Joined: Tue May 12, 2015 2:43 pm
Location: Palmyra, NY
Contact:

Re: Eye Activated Switch

Postby Savage///Circuits » Fri Jul 24, 2015 1:52 am

Jason, I've been a little preoccupied myself and not sure when I will be able to revisit. http://www.wendyjosavage.com/?p=454
Image
I'm only responsible for what I say, not what you understand.

User avatar
Electrons-R-Fun
Member
Member
Posts: 143
Joined: Tue May 12, 2015 7:03 pm
Contact:

Re: Eye Activated Switch

Postby Electrons-R-Fun » Thu Jul 28, 2016 6:27 pm

I got the Eye Switch working to were Lisa or I can turn on an LED. I am just using the Propeller 1.65 volt threshold lever to "see" a signal at an input pin. Although the threshold method works, it also works when Lisa looks to the side or looking around instead of trying to activate the LED. I placed the output on the O-Scope and can measure different time lengths at 3.3 volts (digital signal on or off). So what I want to do, and have started trying with no success, is have a counter count while the signal is high, stop counting once the signal goes low, and run a CASE set of conditional statements comparing how high the counter counted. So if the counter was between 1_000 and 1_250 (1-1.25 seconds) some piece of code would execute. If counter was between 250 and 500 some other piece of code would work.

I am not sure if I have to use the counter register or if I can count in spin like in the below code.

In the code below I tried to make the counter count while holding a button and display the number in the pst. once I let go of the button. If the count was larger than a 1_000 I wanted an LED to turn on for a second then go off. This code did not work and the numbers I got in the pst were very large numbers like 32 bit numbers.

As and example:

Code: Select all

CON

    _xinfreq = 5_000_000                     
    _clkmode = xtal1 + pll1x


Con

   PushButton   = 24
   LED          = 0
   Led_A        = 1

OBJ
   
  pst : "Parallax Serial Terminal"


PUB ButtonLed  | counter                           

    dira[LED..Led_A]~~                     
    pst.Start(57_600)

                                       
                                             
    repeat                                 

     
       
       IF ina[PushButton] == 0
       
           'counter := 0
           'pst.Dec(counter := 0)
            pst.DecIn(counter) := 0
           
           repeat until ina[PushButton] == 1
             pst.Dec(counter++)
             'counter++
             waitcnt(clkfreq / 1_000 + cnt)
           TestMessages
           waitcnt(clkfreq + cnt)
             
          if ((pst.Dec(counter)) > (Pst.Dec(1_000)))    {{((pst.DecIn(counter)) > (1_000))}}
            outa[LED]~~
            waitcnt(clkfreq + cnt)
            outa[LED]~

          ELSE
            outa[LED]~
         
         pst.clear
           
       ELSE
          outa[LED]~
         

PUB TestMessages | counter

   
    pst.home
    pst.Str(String("counter = "))
    pst.Dec(counter)
    'pst.Dec(counter++)
                       


I can't get the above code to do what I want.

I was hoping someone could point out a possible direction to go in.

Jason


Return to “Bio-Medical Electronics”

Who is online

Users browsing this forum: No registered users and 1 guest