Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) My personal Sleep Inducer (Read 26562 times)
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
My personal Sleep Inducer
Jun 20th, 2013 at 4:13pm
Print Post  
Hi all,
I'm a retired baby-boomer. As the years have added up, my body has less ability to generate needed hormones. What's surprising about this is my increased difficulty to fall asleep, stay asleep, attain REM sleep and to re-acquire sleep if awakened. Year after year, the problem grows worse.

I've tried using white noise, pink noise and raindrop sonic generators which helped for a while. Still, I wasn't getting the restorative sleep I experienced in my teens and twenties.

Investigating what others were doing, I discovered numerous Sleep-inducing Solutions on Patent and other web sites. 

My intent has been to create a platform for realizing the various (brain entrainment) pulse signals these patents describe. 

I bought my first Arduino around May 2013 to generate the needed signals. 

Being a Visual-Studio user, it was a natural to get the Visual-Micro addin. When I discovered the VM-debugger, I set about using it to help me understand why certain sections of code were not working (all my fault with poor coding).  

NOTE: The following was accomplished using a long USB cable to access the Arduino Nano. I had to manually disconnect the +5 assembly pin for this to work. Said another way, I was powering my Nano by hooking it to a +5 volt power supply. It was necessary to disconnect from +5 in order to avoid "USB Device Not Recognized" messages from Windows. According to info found on the web, the internal +5 system powered thru the USB cable can get loaded down -- causing this message. I experienced the same problem using the Vin Pin with +11 volts! My solution was to manually disconnect +5 from the Nano pin (before) inserting the USB mini-connector. This allowed me to use a longer USB cable.

I used the VM-Addin to upload my Sketch code to the Nano and the VM-Debugger to troubleshoot mistakes I made. Eventually I had my Nano accurately generating all intended signals. Being able to inspect what was happening at critical junctures made all the difference!

I needed an external interrupt to help me schedule planned signal arrangements. Using VM Debugger Breakpoints, I was able to examine variables set *within* the Interrupt Service Routine.  Cheesy

At first I had problems achieving useful results with the breakpoint in the ISR. But setting Throttle=False, I was up and running no problem. 

I chose External Interrupt-0 driven by a real-time clock signal wired to Digital-Pin #2. My scope shows all signals delivering precise Frequency, Duty-Cycle with no detriment from the 1-second interrupts executed (while reporting back to the Expressions window in my IDE!). Wink

I have yet to deploy my project. Its scheduling will be tested using empirical methods as I hopefully find the magic combination of signals to get me a good nights sleep. Using VM's super Debugger, I have overcome both hardware and software issues in record time. This is the way to go!


Jul 2nd, 2013 at 3:20pm UPDATE:
One of four output channels now working as hoped!  Smiley
Gelius warnings well founded, the Inducer effects stronger than anticipated. (Thanks Gelius)

PROJECT DIRECTION CHANGE
I was originally going to write code and add hardware to support 'configuration' but after reviewing Arduino Serial Comm capabilities, have decided to purchase 'USB extender' devices for a long-run USB cable. Then use my development PC to control the Arduino once deployed. Using a PC app (for Arduino serial comm) would allow easy ways to test protocols as well as capture sensor results.

sv
« Last Edit: Jul 2nd, 2013 at 3:36pm by stockvu »  
Back to top
 
IP Logged
 
gelius59
Junior Member
**
Offline


Posts: 82
Location: Ukraine
Joined: Oct 6th, 2012
Re: My personal Sleep Inducer
Reply #1 - Jun 20th, 2013 at 4:51pm
Print Post  
YOU did a good job.
But sorry subsonic frequency <16Hz can be more dangerous than helpful.
It is your choice but do not cost a risk.
  
Back to top
 
IP Logged
 
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
Re: My personal Sleep Inducer
Reply #2 - Jun 20th, 2013 at 8:58pm
Print Post  
Hi, thanks for the praise.

I failed to reveal the method these signals will be conveyed to the brain. They are as follows;

1) Magnetic -- (A) very low level electro-magnet coils wired in series, or (B) a 40 conductor ribbon cable running the circumference of the boxspring, arranged as a 40 turn coil.

2) ElectroStatic plates -- laid atop the boxspring realized as sheets of side-by-side aluminum foil. Patents have alleged 15 volt signals are enough to affect human physiology. Since I have a mattress between the plates and myself, I will up the voltage in steps of 9 volts using 2U6 style batteries.

3) Light from 660 and 880 nM LEDs. I am planning arrays of 100 each. Not sure how I'll deploy those, I do have information alleging benefits to human physiology from the RED (660) and infraRed (880) wavelengths.

Sonics are not planned. I forgot to describe the delivery method.


best regards,


« Last Edit: Jun 28th, 2013 at 4:00am by stockvu »  
Back to top
 
IP Logged
 
gelius59
Junior Member
**
Offline


Posts: 82
Location: Ukraine
Joined: Oct 6th, 2012
Re: My personal Sleep Inducer
Reply #3 - Jun 21st, 2013 at 2:22am
Print Post  
Hello.
Now it is clear to me anymore.
But even so, you have to be careful.
Believe me I know what I'm saying.
Sincerely.
PS.This effect on the body that is more mystery than the Arduino.  Smiley
The safest of the above paragraph 3. light

Good luck.
« Last Edit: Jun 21st, 2013 at 7:41am by gelius59 »  
Back to top
 
IP Logged
 
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
Re: My personal Sleep Inducer
Reply #4 - Jun 22nd, 2013 at 7:40pm
Print Post  
Hi again,

You may find the following link of interest. It describes construction of an easy to make electronic Sleep-Inducer using pulsed magnetism (I have not built or tried). It uses a small inductor made from a bolt wound with wire. The Author claims good results. 

http://consultprojects.blogspot.com/2010/04/electronic-sleep-inducer.html

When I read this article I was very interested and decided to research the web and patents for even more ideas. 

That said, my aim here is to get good, restorative sleep -- having an occasional power-nap would be nice too.  Wink

best regards,

« Last Edit: Jun 28th, 2013 at 4:00am by stockvu »  
Back to top
 
IP Logged
 
gelius59
Junior Member
**
Offline


Posts: 82
Location: Ukraine
Joined: Oct 6th, 2012
Re: My personal Sleep Inducer
Reply #5 - Jun 23rd, 2013 at 3:43am
Print Post  
Hello
I'm glad you know what I mean.
I watched the concept that there is a prototype for solving your sleep.
It is extremely simple and therefore not devoid of drawbacks.
For example the stability of timeslots.
While giving the circuit a capacitor and a resistor.
It is difficult to provide stability without special measures.
As I understand it must be high in order to achieve proper results. 

You have selected the correct direction Arduino solutions.
You will be able to obtain stable frequency.
And if you want to quickly change them if need be.

I think in conjunction with this excellent development environment for  Visual micro
together with a debugger that helps you locate programming errors.
Your achieve good results.

Sincerely.
Good luck.
« Last Edit: Jun 23rd, 2013 at 6:55am by gelius59 »  
Back to top
 
IP Logged
 
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
Re: My personal Sleep Inducer
Reply #6 - Jun 23rd, 2013 at 4:22pm
Print Post  
Hi,

I appriciate your input and agree that repeatable frequency stability and accuracy is important for this to have a chance of working. 

As to Arduino, I totally agree! My original approach was to use TTL CMOS chips arranged in the most flexible configuration. The Arduino-Nano eliminated many chips while expanding capability and flexibility. Making changes to code trumps rewiring in my view.  Smiley

best regards,
« Last Edit: Jun 23rd, 2013 at 4:30pm by stockvu »  
Back to top
 
IP Logged
 
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
Re: My personal Sleep Inducer UPDATE
Reply #7 - Aug 8th, 2013 at 4:51pm
Print Post  
Aug 8th, 2013 at 4:27pm UPDATE

Its unfortunate I cannot add Updates to the original Post -- it flowed better IMO.

I've had some success with the new Command-Language to run my Sleep-Inducer platform via Serial. But, only after much head-banging using Strings within Arduino C++. Tongue 

I'm a VB.Net type -- accustomed to having loads of RAM holding String literals and variables. But in my Nano 3.0, I used too much volatile memory. I was spinning my wheels for weeks! I couldn't understand what was happening, symptoms came and went as I made minor changes to code. 
 
However, with the VM Performance Visualier, I was able to see the impact specific statements had on free RAM. As soon as I approach 250-300 bytes free, my software becomes unpredictable, even crashes the CPU -- all of which was NOT easily understood since I had no way to single-step and inspect code (as you can in VB.Net). 

As for the new Command-Language, it uses a [Target]-->[Command]-->[Parameter(s)] approach. First the Target object is resolved, allowing me to reference the appropriate control Struct, then the Command (and Params) are resolved to modify variables in said structure. It seems to work once you get past all the String and memory gotcha's.

The reason for a Command approach like this is to Log each Command and Response along with Date-Time info resulting in easy to understand reports for later evaluation. 

LANGUAGE EXAMPLE (send only, no response or time info) 
================
MAG_STOP
MAG_AM-OFF
MAG_MODE(MFF)
MAG_PARAM(FM)_0.025_2.0_-2.0
MAG_FM-ON
MAG_RUN
================

The good news: this approach seems to work. The bad news: more research and coding required to avoid the memory issues.


sv
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: My personal Sleep Inducer
Reply #8 - Aug 8th, 2013 at 5:29pm
Print Post  
Nice, I like request and response command systems, always seems to be neat and avoids spaghetti bugs

I am trying to look into why you can't edit your posts. Everyone is supposed to be able to edit without time limit. If you find time to send me a screen shot of whatever you see when looking at the posts in this thread it would be appreciated. Thanks
  
Back to top
IP Logged
 
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
Re: My personal Sleep Inducer
Reply #9 - Aug 9th, 2013 at 3:05pm
Print Post  
Hi Tim,

Sorry for giving the wrong impression -- I have no problem editing posts save for reaching the 4000 char limit. That's why I couldn't add Updates to the starting post. Smiley


sv

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: My personal Sleep Inducer
Reply #10 - Aug 9th, 2013 at 3:24pm
Print Post  
Oh that makes sense. Maybe the limit should be increased. Thanks
  
Back to top
IP Logged
 
stockvu
Junior Member
**
Offline


Posts: 24
Location: USA
Joined: Jun 12th, 2013
Re: My personal Sleep Inducer: UPDATE (Arduino SRAM Problems Solved)
Reply #11 - Sep 1st, 2013 at 7:25pm
Print Post  
Hi All,

Update: Arduino Memory problems SOLVED

Using the VM Debugger and some code found at StackExchange,
http://stackoverflow.com/questions/8873998/arduino-string-array-not-deallocated-...
I learned why SRAM was apparently disappearing -- causing occasional failures when my Command-Language was active. 

I don't claim to be an authority on SRAM, Arduino or ANYTHING -- but the following is what worked for me;

Problem-1: Passing String objects as Parameters
My use of String-Objects passed-as-parameters caused high spikes in SRAM allocation. Memory was freed after Function call completion but SRAM was sometimes too low for proper operation during the call (depending on SRAM level and String size). I lost much time chasing this down. Sad 

MY SOLUTION: Don't pass String Objects as parameters! 


Problem-2: Scattered String Literals
In achieving a workable control language, I used String Literals to help me Parse commands and Print status messages. Eventually I learned doing this causes Allocation of both SRAM and Program Memory for each Literal String! 

MY SOLUTION: Use the PROGMEM approach for String literals found at http://arduino.cc/en/Reference/PROGMEM. This technique eliminated much wasted SRAM.


Problem-3: Sending long Serial 'Commands'
Sending long Command-Strings into my controller's Serial port caused free SRAM to drop and remain lower! The reason was my allowing the 'inputString' object to accept any amount of characters and allocate SRAM as it needed.

MY SOLUTION: Limit the 'length' of inputString to a useful but economical size (I chose 90 bytes for my Command-Language).


I'll post later on how I tracked this stuff down! 


CURRENT PROJECT STATUS  Cool
My Nano and VB.Net control-program are happily exchanging Command and Status info. Free SRAM is starting off at 900+ bytes and now only drops to 700 or so after processing numerous commands. Before I was seeing SRAM drop to near 300 before things fell apart.

Now working on the Scheduler portion of the VB app.


sv
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: My personal Sleep Inducer
Reply #12 - Sep 1st, 2013 at 11:22pm
Print Post  
This is useful info. I was also looking at PROGMEM earlier today.

I these these points are really important, so many people run out of memory and their projects become useless. So knowing these points early and clearly can avoid a lot of re-write and frustration. I know!!

It is always great to read your posts, thanks
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint