Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Project Guidance / Connect EasyVR differential pwm audio output to an amplifier on: April 14, 2014, 06:47:46 am
My EasyVR shield has two PWM outputs that connect to a speaker.  They also included a line out that could be connected to an external amplifier.  When I try to use this line out connection, the resulting audio is less than impressive.  The biggest issue being that it sounds as if the audio is clipping.  If hooking the speaker directly, PWM0 goes to one terminal on the speaker and PWM1 goes to the other.  But on the audio output, PWM0 goes to Left and PWM1 goes to right.  The two signals alternate so that it pushes and pulls the speaker in both directions using ground as a reference..  My guess is that I need to hook these two outputs through a low pass filter to smooth out the square edges, then each to separate op amps to offset the voltages and then feed into a third op amp that drives one input on an audio amplifier..  Is my approach generally correct?  Or should I have the low pass filter elsewhere, such as at the output of the third op amp?  Do I need three op amps?  Or will one suffice?
2  Using Arduino / Project Guidance / Building my own PCB, Pwned by crystal issue on: April 05, 2014, 10:38:49 am
I've made several PCBs before using the SMD version Atmega 168/328 chips and not had any issues.  But I changed the crystal in my most recent design because I needed something smaller.

I'm running the test at 5v with 16mhz, although I successfully tested the same design on breadboard running 3.7v at 16mhz with a thruhole crystal.

I thought it would be trival to substitute a thru-hole 16mhz 18pf crystal with this SMD variant:

My PCB didn't have room for USB connections, so what I did was put in the ISP header, upload the sketch to a working Arduino variant with the same Atmega328P, and read the flash contents with my MKII from the working board and write it to my PCB.  All that works fine.  But I can't get the sketch to run on the new PCB for the life of me.

I set my fuses as follows: Extended 0xFD, High 0xDA, Low 0xFF.  The crystal seems to oscillate at 16mhz, but basically only between Gnd and 1V.  If I change to use ExtFSCrystal at max settings, the crystal oscillates at 16mhz between about 1.25v and 3.75v.  In neither situation will my sketch run properly (even putting a simple sketch like blink and scoping the output pin doesn't work).

3  Using Arduino / Audio / Arduino Uno + EasyVR Shield train Speaker Dependent commands on: May 12, 2013, 02:50:03 pm
I have gotten pretty deep into testing this module and have most features working.  I even went as far as to load the EasyVR Bridge sketch, used EasyVR Commander and manually trained the commands on the PC.  I can get it to recognize these commands via recognizeWord(group) no problem. What's got me stuck is trying to train a speaker-dependent command offline (directly through Arduino code, not using EasyVR Commander in bridge mode).  Has anyone else gotten this working?  From the looks of page41 of the Easy VR manual, you just need to call easyvr.trainCommand(group,index) and then poll hasFinished() until true.

but, when I execute this, and continuously poll hasFinished, it always returns false.  It theoretically should time out after a few seconds.  I even tried using eraseCommand(group,index) first (it returns true) before using the trainCommand, but still get the same result.
4  Using Arduino / Programming Questions / Re: Parsing an incoming string (losing data somehow) on: January 10, 2013, 08:39:52 am
PaulS.  You're basing that on Nick Gammond's snippet of the code I posted, where he removed some of the routines in question to point out what he thought was causing the issue.  In my original post, you will see that I used an If (Serial3.available()>0) before the do/while loop took over.

I just don't understand how I can lose data with something as simple as two asynchronous ports listening at 9600 baud to receive a short packet of 28 bytes once every second.  It works flawlessly if I merely receive and pass the data through and don't do anything else with it. 

I know through observation that when I use "Serial.find", I lose all the data in the Serial buffer that occurs before and including the string I'm searching for.  Is it just not an efficient routine to use that I would be better off writing my own find routine? (I couldn't find anything other than doing a bunch of nested if statements in a For loop.   Do I need to increase the serial buffer somehow or is it adequate to hold 56 bytes from each port in the worse-case scenario?
5  Using Arduino / Programming Questions / Re: Parsing an incoming string (losing data somehow) on: January 10, 2013, 12:54:27 am
I tried commenting out all of the print statement during the capture/parsing, but I still get some missed data (I left in just small part of the checksum that shows it failed).  Now, I don't see why it failed, but I can see that some character must have been missing since it shows the last byte it thought was checksum is one of the "zero" bytes..  I even disconnected the second sensor so I'm only getting data on Serial3..

Does using the Serial2.find(\xA5\xA5\x85) routine block Serial3 from receiving any bytes??
6  Using Arduino / Programming Questions / Re: Retaining Variable Value in Arduino - Possible? on: January 10, 2013, 12:13:53 am
Another possibility is check the peripheral chips you're using.  Sometimes they offer a place to stash a few bytes.  For instance, I use the DS1305 RTC in one of my projects.  it has 96 bytes of user RAM that is battery-backed.  No finite cycles to worry about.  I think the DS1307 and others have similar.  You could also consider adding a Serial ROM chip.
7  Using Arduino / Programming Questions / Re: Communication with 2 x DS18B20 on: January 10, 2013, 12:09:32 am
I designed a controller on my diecemilia using two separate one-wire busses on digital pins 17 and 18 (the analog pins as all others were used)

I basically just had a separate onewire instance for each bus and had a routine to pick which bus to poll based on where the sensors were remembered.
OneWire DS1(17);
OneWire DS2(18);

That got me around a lot of the problems I initially had.

But the main fix I found was actually regarding bus capacitance or something like that.  The 4.7k pullup resistor is a bit weak for longer busses.  Switch to a 1k pullup and things should improve a lot.  I have 7 sensors spread out on one bus, using 18ga "Sprinkler wire" over 50ft in total length, with short stubs from the main bus to each sensor.   It has worked flawlessly for 5 years.  Cat5 cable also seems to work good.  Use one pair for power and ground, and one wire from another pair for the DQ pin.
8  Using Arduino / Programming Questions / Parsing an incoming string (losing data somehow) on: January 10, 2013, 12:00:24 am
I'm trying to read a stream of data from two existing sensors.

I have one sensor hooked to the Serial2 RX and the other to Serial3 RX.  They both output a packet of data about every second.  The packet consists of 28 characters.  The first few could be considered a "preamble" sequence as it never changes.  The last byte being a checksum value of everything after the first few packets added together, modulo'ed, then subtracted from FF.  If this last byte matches the calculated checksum, everything is deemed to be good.  There is no defining termination sequence, (IE there is no CR/LF like you would get from a GPS) to tell the end of the sequence.

I used this code initially to see my sequence:
    Serial.print("S3 in=");
      Serial.print(", ");
    while (Serial3.available()>0);

My resulting serial stream looks like this:
S3 in=, A5
S3 in=, A5
S3 in=, 85
S3 in=, 61
S3 in=, 0
S3 in=, 0
S3 in=, 0, 0, 10, 0, 0, [color=purple]0, E[/color], 0, 0, [color=red]0, 18[/color], 0, 0, 0, 2A, 0, 0, 0, 66, 9, 0, 0, EF
Despite the unobvious delays reported above, all of the data comes in "at once" as far as my eyes can see, with the majority of the one-second interval being silent.
All of the bytes are there regardless how I exercise the sensor inputs

I specifically need to capture 4 bytes.. The preceding 0x00 and 0x0E together and the preceding 0x00 and 0x18 together and store them in two ints.  The rest of the data I don't care about once the checksum passes.

I tried the following code to parse the data (not even getting to the part about storing the bytes yet) but I'm apparently occasionally losing bytes at various points in the middle somehow as I exercise the sensor inputs:
Is there a better way to do this that would prove more reliable?  Am I doing any major coding f aux-pas? Any idea why I'm losing random bytes occasionally in the following code sample?
    Serial.print( "S3 bit stream =");
    byte c=0;
      Serial.print(", ");
      Serial.print(", ");
    checksumcheck=(checksums3 % 0x100);
      Serial.print(" S3 Checksum failed: Received ");
      Serial.print(" counted ");
      Serial.print(" expected ");
      Serial.println();//" Good Checksum");
    Serial.print(" Left ");



9  Using Arduino / Programming Questions / Re: Capturing a digital pulse mixed in an analog signal on: January 03, 2013, 09:48:17 pm
The noise is more of a slowly increasing DC offset rather than a random distribution.     My current logged dataset revolved around an arbitrarily picked midpoint and ignored logging anything below that point.  Once the signal  exceeded that midpoint and subsequently dropped below it again, I logged the 25 previous samples.  When I did a histogram on that cumulative bit of data, I found 2 peaks..  The main one being the low (with some 45k+ points) and the other surrounding the average high point (with a peak of about 5k points).  So it seems like if I create a slowly periodic histogram with a slow decay(to cast out the outliers), my controller can identify and focus on those two peaks, get a mean value for each and use that to scale the input and set my threshold.  If I use standard deviations on those two peaks separately, I can minimize the need to frequently do square root calculations and keep my sample rate and accuracy high.
10  Using Arduino / Programming Questions / Re: Capturing a digital pulse mixed in an analog signal on: January 03, 2013, 09:01:48 pm
Is sigma the same as Standard Deviation?  (I think the answer is yes..)  Never took calculus and struggling to wrap my head around bits of it as I dig around online.
11  Using Arduino / Programming Questions / Re: Capturing a digital pulse mixed in an analog signal on: January 03, 2013, 07:36:21 pm
Close enough analogy.. minus the dialtone. 
12  Using Arduino / Programming Questions / Re: Capturing a digital pulse mixed in an analog signal on: January 03, 2013, 12:33:56 pm
in my current sketch,  it's running full speed,  pulling samples and doing median as well as mean calculations.  when I feed a constant stream of 25 samples and then dump it to serial,  I got an estimated 2-3 Ms between samples.  about 30Ms pulse time is all I could find for info,  supported mostly by my sample rate which indicated about 26Ms when looking at the high periods logged.  something like 65Ms to process those 25 samples.  don't have access to my code,  but will try to get a snippet up later.
when I looked up info on standard deviation, it looks like I would be doing a lot of squares and square root functions..  and I was a bit worried whether I could do all that work in enough time to keep the sample rate up.
thinking about it this morning,  I thought about Using standard deviation to separate the highs from the lows,  then processing standard deviation on the high periods alone,  then scaling the data with a slope function and seeing the trigger levels at 30% and 70% of those values accordingly.  sound like a solid plan?
13  Using Arduino / Sensors / Re: IR detector under direct sunlight on: January 02, 2013, 10:18:40 pm
To overpower the sun, you probably should consider going back to IR LEDs.  get very narrow-range ones and use several of them in a tight cluster.  This gives you several degrees of allowable mis-alignment and still being within the 50% cone of visibility..  The idea being to overpower the sun with the focused energy.  Modulating the signal helps, but make sure you use something that can capture and read the signal (usually at 4x faster sample rate from the signal)  to help while filtering out the background noise.  The other thing that helps is installing a shield to block out light that is coming in off-angle from your sensors.  a good shield could be as simple as a narrow tube painted flat black inside, with the receiving sensor in the back of the tube.  The length and diameter of the tube can be adjusted to allow for mis-alignment, but the sensor needs to be far back enough to reduce outside light being allowed to reflect in and drown out your signal
14  Using Arduino / Programming Questions / Capturing a digital pulse mixed in an analog signal on: January 02, 2013, 09:53:45 pm
I'm looking to capture a digital pulse (read via an IR phototransistor on an analog input), and filter out the noise while automatically calculating and continually adjusting the trigger point.  My digital pulse is about 30ms, surrounded by long periods (600-160000+ms) of silence.  It seems like I can capture from 2 to 11 ADC samples during that high pulse in my current sketch, which includes sending data out the serial port and updating an LCD display every 10 samples.  The important variable here is the interval between each pulse.

In my current sketch, I started out reading the analog value and adding it to an array of 25 int as a circular buffer, which I sort to calculate the median and mean values of the array. My "noise" currently varies from 0 at night to about 50 ADC counts over the last day and a half, but I'd like to do my best to make sure I don't have to get in and tweak the sketch in the summer just because the noise got a little higher than a hard-coded trigger value.  My peak ADC value for the digital high period has been as high as 800-900, but seems more towards an average of 300-400 adc counts during the period of samples where a high was captured.  A friend suggested I do a FIR or FFT on the data, but that seems more geared towards a consistently repeating frequency rather than a pulse that could have a random delay between each period.  Would it be to my benefit to use one of those filters or would I be fine to just calculate a standard deviation on the samples collected? Is my buffer large enough or should I double it?

Once I have the information, my thought was to normalize the noise down to zero and scale the peaks to max, and then pick a number somewhere in the upper-middle as the transition level.. thus, hopefully maintaining a healthy response until the noise completely drowns out the signal.
15  Using Arduino / Displays / Re: PWM control LCD Contrast on: September 23, 2012, 10:35:33 pm
I'll concede in the old days, everything had knobs... and knobs to control knobs!.  But in the last 10+ years, those knobs all but disappeared, and the products became more user friendly and 'smart'..  If it still had an adjustment, it was one of those "Fn" + "F5" to decrease or "Fn" + "F6" to increase, etc...  Why put 10 buttons if most of the needed functions can be dealt with in short menus with only 4 buttons?  Move the 3 highest priority items up to the main menu with just one button to get a menu the less-used items.

As for the mosfet, I thought with a high-side mosfet, you had to be close to the upper voltage to turn on, so that it should have worked. 
what if I moved it to the middle of the voltage divider and then used a low-side mosfet?
Pages: [1] 2 3 ... 8