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 » Fri Jul 29, 2016 4:18 am

Sorry Guys,

It seems writing code is a perishable skill, since I haven't written anything in a long time with the combination of training a new new nurse,(that's a long bad story) I was simply not able to think clearly.

I have some code I am happy with and it mostly works, the strange thing is, the baud rate for the pst on 115_200 writes gibberish but the 57_600 writes normal. Don't know if that's because I am working through a usb 3 or some other reason I don't understand.

The other strange thing is when I use clkfreq/1000 + cnt and I hold the button down for a secondish I only get about 60 counts instead of a 1_000, not that big of a deal I just thought clkfreq / 1000 + cnt would pause every 1ms.

Code: Select all

CON

    _xinfreq = 5_000_000                     
    _clkmode = xtal1 + pll1x


Con

   PushButton   = 0
   LED          = 1
   Led_A        = 2

OBJ
   
  pst : "Parallax Serial Terminal"


PUB ButtonLed  | counter                           

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

     
       
       IF ina[PushButton] == 0


           pst.clear
           counter := 0
           waitcnt(clkfreq/200 + cnt)
           
           repeat until ina[PushButton] == 1
              counter++
              waitcnt(clkfreq / 10 + cnt)
              pst.home
              pst.Str(String("counter = "))
             
              pst.Dec(counter)
             
         
           
         if ((counter > 5) and (counter =< 10))
           outa[LED]~~
           waitcnt(clkfreq + cnt)
           outa[LED]~
         
         if ((counter =< 5) and (counter > 2))
           repeat 20
             !outa[Led_A]
              waitcnt(clkfreq/4 + cnt)
           
           
       ELSE
          outa[LED]~
          outa[Led_A]~


In the above code I use clkfreq/10 + cnt because it made the counts easier to work with but I did try 1_000 and the count is only about 60. NO big deal I can just see how the count relates to Lisa's eye movement and write the code based on what ever numbers fit best, just wanted to be able to break it down into smaller increments to give me more room to work with for my windows.

Jason

User avatar
Granz
Member
Member
Posts: 130
Joined: Sun May 31, 2015 2:37 pm
Location: Pittsburgh, PA, USA, Terra, Sol, Andromeda Arm, Milky Way Galaxy, Milky Way Cluster, Local Universe
Contact:

Re: Eye Activated Switch

Postby Granz » Sat Jul 30, 2016 12:49 pm

Jason,

It has been quite a while since I have done anything with the Propeller, and never with Spin. But, have you allowed for keyboard bounce? That is, whenever two conductors make contact, there is a short period of time where the conductors bounce against each other, before they settle into connection. Since the Prop works in the microsecond realm, the controller can actually see the bouncing as multiple presses - thus reading dozens to hundreds of "circuit closed" signals per press of the button. I don't see anything in your code (unless the INA statement can handle bounce.) Again, I am not a Prop expert, but have run across this before with other controllers; maybe start with that, though.
Art G. Granzeier III, President
GranzTronix
http://projects.granzeier.com
Helping to Build a Better Engineer

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 » Sun Jul 31, 2016 3:19 pm

Hi Art,

Thanks for the reply. I did get the package you sent, but never got to use it. We never got to go on vacation due to the morning nurse rupturing Lisa lungs by being negligent and not allowing Lisa's vent to exhale for about two minuets, Lisa had to be hospitalized and ended up getting pneumonia from her lungs bleeding for days. In fact, if I wasn't home and I hadn't built wireless alert stations that go off throughout the house when the vent alarm goes off, Lisa would have died. So once again, electronics help Lisa and save her life again.

I thought Switch bounce was a fascinating subject when I first learned about it. I remember reading an article in nuts and volts that had to deal with coding for switch bounce, but the code was to complex for me and I didn't understand it all. The easiest way I known how to control switch bounce is with a time delay after the switch is closed to allow the bouncing to settle. Usually a delay of about 200 ms is what I recall being the minimum amount of time.

I know I am pressing a button, and switch bounce is a real life issue, I did not seem to have my counter stop counting and start again while watching the pst.

I can see your suggestion is excellent, and based on many years of experience working in the industry.

The eye-switch output signal is a digital signal and I wasn't thinking of switch bounce, as digital signals don't have switch bounce, but your right, I should have but some code in for switch bounce for my testing application of using the push button on the PPDB and then just take it out in my final code for the eye-switch. I will substitute waitcnt(clkfreq/5 + cnt) after pst.clear to help with the possibility of switch bounce.

Jason

User avatar
Granz
Member
Member
Posts: 130
Joined: Sun May 31, 2015 2:37 pm
Location: Pittsburgh, PA, USA, Terra, Sol, Andromeda Arm, Milky Way Galaxy, Milky Way Cluster, Local Universe
Contact:

Re: Eye Activated Switch

Postby Granz » Mon Aug 01, 2016 2:21 pm

Electrons-R-Fun wrote:Hi Art,

Thanks for the reply. I did get the package you sent, but never got to use it. We never got to go on vacation due to the morning nurse rupturing Lisa lungs by being negligent and not allowing Lisa's vent to exhale for about two minuets, Lisa had to be hospitalized and ended up getting pneumonia from her lungs bleeding for days. In fact, if I wasn't home and I hadn't built wireless alert stations that go off throughout the house when the vent alarm goes off, Lisa would have died. So once again, electronics help Lisa and save her life again.

Wow, glad that you had the stuff together, and were home. We'll pray for her tonight.

About the not using the stuff, yet - no problem, the expiration date is WAY the heck out there. ;-) You can use the stuff later on, when you do go on vacation.
Electrons-R-Fun wrote:I thought Switch bounce was a fascinating subject when I first learned about it. I remember reading an article in nuts and volts that had to deal with coding for switch bounce, but the code was to complex for me and I didn't understand it all. The easiest way I known how to control switch bounce is with a time delay after the switch is closed to allow the bouncing to settle. Usually a delay of about 200 ms is what I recall being the minimum amount of time.

I know I am pressing a button, and switch bounce is a real life issue, I did not seem to have my counter stop counting and start again while watching the pst.

I can see your suggestion is excellent, and based on many years of experience working in the industry.

The eye-switch output signal is a digital signal and I wasn't thinking of switch bounce, as digital signals don't have switch bounce, but your right, I should have but some code in for switch bounce for my testing application of using the push button on the PPDB and then just take it out in my final code for the eye-switch. I will substitute waitcnt(clkfreq/5 + cnt) after pst.clear to help with the possibility of switch bounce.

Jason

Ok, I didn't think about the fact that you are getting a digital signal there. But, like you said, you will still need to use something for key bounce for your simulation.

Let us know what you find out.
Art G. Granzeier III, President
GranzTronix
http://projects.granzeier.com
Helping to Build a Better Engineer

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 Aug 04, 2016 2:40 pm

After placing a delay for switch bounce, there was no difference in how the code works. I have since hooked up the eye switch to the ppdb and have Lisa using the matrix grid successfully about 90% of the time, pretty good straight out of the box. Lisa using the matrix grid to speak, " I want a Soda". :lol:

I think I will use a DIP switch to make the comparetor windows range into variables and display what the current settings are on the LCD. That way, if Lisa's current needs change, the device will have a little flexibility to adapt.

Have to go cops just showed up about rv being parked outside, even though I have permit.

Jason

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

Re: Eye Activated Switch

Postby Savage///Circuits » Thu Aug 18, 2016 12:58 pm

What about reading the current system counter? For example, when you get the first pulse:

Code: Select all

  cnt1 := cnt                                                                   ' Store Current Counter Value

Code: Select all

  cnt2 := cnt                                                                   ' Store New Counter Value

Code: Select all

  Microseconds := (||(cnt1 - cnt2) / (clkfreq / 1_000_000)) >> 1                ' Return Time in µs


I do this in the PING))) object and the return us using the following math. However you could return a different resolution value for your application or just the number of clock counts.
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 Aug 19, 2016 3:35 pm

HI Chris and thanks for the reply.

My original thought was to do exactly as you said, to use the system counter to measure the amount of time the "on" signal is being generated. I tried something based on the code in the PE kit book on page 75 figure 5-6, but my code did not work, probably because my code did not look like the code you wrote.

I do have the project working, it actually works really well and makes communication with Lisa unbelievably easier, but it's not perfect. Lisa can not wear the "sticky tabs" everyday, she has developed a blistering rash wear the sticky tabs were placed on her skin.

I have some dry electrodes I can use, but they create several other problems, mostly good contact issues.

I will make a video of what I have working so far and put it on YouTube, I struggle to make the pictures the correct size on the website.

I will incorporated your code into mine and see how it works and how to use it, but I am also thinking about using this same style of code for the LISA alarm since Lisa continues to use that device everyday successfully.

I thank all those that continue to take an interest in the projects I build and make great suggestions on components or code, that can improve my knowledge of components and codding so I grow and make better devices for Lisa and others.

Jason

User avatar
Granz
Member
Member
Posts: 130
Joined: Sun May 31, 2015 2:37 pm
Location: Pittsburgh, PA, USA, Terra, Sol, Andromeda Arm, Milky Way Galaxy, Milky Way Cluster, Local Universe
Contact:

Re: Eye Activated Switch

Postby Granz » Sun Aug 21, 2016 3:21 pm

Electrons-R-Fun wrote:... but it's not perfect. Lisa can not wear the "sticky tabs" everyday, she has developed a blistering rash wear the sticky tabs were placed on her skin. ...

We have a friend who has some bad health problems, and needed to stay on a heart monitor for a long time (weeks? months? I don't remember for sure) but her health problems caused severe rash where the electrodes were placed. She got some relief by using (IIRC) pediatric monitor pads. They may also have been neonatal pads, I will see her tonight and ask her then.
Art G. Granzeier III, President
GranzTronix
http://projects.granzeier.com
Helping to Build a Better Engineer

User avatar
Granz
Member
Member
Posts: 130
Joined: Sun May 31, 2015 2:37 pm
Location: Pittsburgh, PA, USA, Terra, Sol, Andromeda Arm, Milky Way Galaxy, Milky Way Cluster, Local Universe
Contact:

Re: Eye Activated Switch

Postby Granz » Sun Aug 21, 2016 10:09 pm

Jason,
Confirmed, Bethany said that she used the pediatric electrode pads, and that they were way better for her skin. She also told me to let you know that if you call the distributor where you got the adult electrodes, they may be willing to just swap them out for ped versions. She did get hers through her regular doctor/medical channels, though - so your mileage may vary.

Also, if you are not getting them through Lisa's doctor, show the thing to him and he may be able to get her insurance to pay for the electrodes; you never know until you try.
Art G. Granzeier III, President
GranzTronix
http://projects.granzeier.com
Helping to Build a Better Engineer

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 Aug 22, 2016 2:46 pm

Sent Company email, I'll let you guys know.

Thanks for the information Art.

Jason


Return to “Bio-Medical Electronics”

Who is online

Users browsing this forum: No registered users and 5 guests