Show Posts
|
|
Pages: [1] 2 3 ... 5
|
|
1
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Arduino serial read in script keeps hanging. Ideas?
|
on: September 04, 2012, 03:52:17 pm
|
I never found the root cause. I hacked some code together that can spot the problem. reader.sh #!/bin/bash TMP_DATE="/dev/shm/tmp.date.txt" date +%s > $TMP_DATE
while read CHAR do echo "${CHAR}" | logger date +%s > $TMP_DATE done < /dev/ttyUSB0 watcher.sh (Setup to run from cron once a minute) #!/bin/bash #Version=0.5
HOME_PATH="/root/bin" SCRIPT="serial_watcher.sh" FULL_PATH="${HOME_PATH}/${SCRIPT}" TMP_DATE="/dev/shm/tmp.date.txt"
#Check: Has it run in the last 7min (420 sec) CURRENT_TMP_DATE=`date +%s` LAST_WRITTEN_DATE=`cat $TMP_DATE` DIFF=$(($CURRENT_TMP_DATE - $LAST_WRITTEN_DATE))
if [ $DIFF -gt 420 ];then logger "$0 ERROR: $SCRIPT has not responded in $DIFF seconds, restarting" killall $SCRIPT nohup $FULL_PATH & fi
|
|
|
|
|
3
|
Using Arduino / Interfacing w/ Software on the Computer / Arduino serial read in script keeps hanging. Ideas?
|
on: August 29, 2012, 10:17:18 am
|
I have a solar powered Arduino Fio out in a field playing weather station. All the data is get transmitted back over a XBee net. Last week I upgraded from XBee 2.4GHz's to XBee 900's. Now my serial_watcher.sh script crashes/hangs ever 4~6 hours. serial_watcher.sh #!/bin/bash
while read CHAR do echo "${CHAR}" | logger done < /dev/ttyUSB0 In a crashed state the script is still running, but no data is coming in. # ps -ef | grep serial root 13147 1 0 Aug28 ? 00:00:23 /bin/bash /root/bin/serial_watcher.sh I am stumped on this one. Nothing in dmesg/messages. Yet is works fine for weeks on end with a 2.4GHz XBee. If I restart my script every thing start working again, for a few hours. # kill 13147 # nohup /root/bin/serial_watcher.sh & XBee 2.4GHz https://www.sparkfun.com/products/8710XBee 900 https://www.sparkfun.com/products/9098Any ideas?
|
|
|
|
|
4
|
Using Arduino / Programming Questions / Hardware interrupt with a 555 Timer, or internal timer, with a sleeping arduino?
|
on: July 20, 2012, 03:50:37 pm
|
Question: Is it possible to use a timer to wake an Arduino once every 5 minutes, regardless of how long the code takes to run? I know I can do this with a hardware interrupt and 555 timer set to pulse once every 5 minutes, but I would rather not add extra hardware. What I have: Execute code --> Sleep 5m = 5m + execution time for each cycle What I would like: Start 5m timer, Execute code and go to sleep, sleep until the 5m timer expires = 5m for each cycle, regardless of execution time The setup: I have an Arduino Fio (V2) attached to N number of DS18S20 temperature sensors. The Fio is solar/battery powered and transmits data back home via XBee. The Fio/XBee are set to deep sleep for about 5 minutes between reads. I would like new data every 5 minutes (+/- a few seconds). With the addition of each DS18S20 the sampling time goes up. I am using the Arduino Narcoleptic http://code.google.com/p/narcoleptic/ code to put my Fio to sleep. My current watt draw when asleep is less then any meter I own can read. :-) My current sleep code is rather dumb //28 = about 5min including code execution time for (int i=0; i < 27; i++) { Narcoleptic.delay(10000); }
Any ideas on how to do this with out adding hardware?
|
|
|
|
|
9
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: How do I set TCNT2 for XXXXX Hz
|
on: November 19, 2010, 10:27:15 pm
|
Counting cycles across my old scope's screen. With the old code I could get a max of 1.75 complete cycles. With the new code I get 5.5 cycles. I can get 9 cycles when I remove the 'for' loop! So It would seem that the 'for' loop is costly! It may be a better move to use a much bigger wave table and vary the number of cycles in the wavetable in order to achieve different speeds. //byte wavetable[32] = {128, 154, 178, 201, 220, 236, 247, 254, 255, 251, 242, 228, 211, 190, 166, 141, 115, 90, 66, 45, 27, 14, 5, 1, 3, 9, 20, 36, 56, 78, 103, 128}; byte wavetable[32] = {0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255}; byte delay_length = 0; byte i = 0; unsigned int z = 0;
void setup() { for (z = 0; z <= 7; z++) { pinMode(z, OUTPUT); } }
void loop() { PORTD=wavetable[i];
i++; if (i==32) i=0; else asm("nop\n nop\n nop\n");
/*for (z = 0; z <= delay_length; z++) { asm("nop\n"); }*/ }
|
|
|
|
|
11
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: How do I set TCNT2 for XXXXX Hz
|
on: November 19, 2010, 04:20:33 pm
|
If a single wave form is defined by 32 points. How fast do you think we can go? byte wavetable[32] = {128, 154, 178, 201, 220, 236, 247, 254, 255, 251, 242, 228, 211, 190, 166, 141, 115, 90, 66, 45, 27, 14, 5, 1, 3, 9, 20, 36, 56, 78, 103, 128}; byte i = 0; byte delay_length = 0;
void setup() { for (byte z = 6; z <= 13; z++) { pinMode(z, OUTPUT); } }
void loop() { PORTD=wavetable[i];
i++; if (i==32) { i=0; } else { asm("nop\n nop\n"); }
for (byte z = 0; z <= delay_length; z++) { asm("nop\n"); } }
|
|
|
|
|
13
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: How do I set TCNT2 for XXXXX Hz
|
on: November 19, 2010, 01:46:53 pm
|
I need to look at the assembly code for i=0, and replace the i=i with the correct amount of clock cycles: asm("nop\n nop\n nop\n nop\n"); I can also use an assembly based delay, if I need less over head. If need be I can write the whole delay in assembly. for (int z =0; z <= foo; z++) { asm("nop\n"); } The other potential problem is the Timer 0 (millis) interrupt service routine. At seemingly random points it will run and interfere with loop. Can I just shutdown timer0? Or will I break other stuff?
|
|
|
|
|
14
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: How do I set TCNT2 for XXXXX Hz
|
on: November 19, 2010, 10:53:13 am
|
Lets see if I can describe this all correctly. Two Arduino's; one for signal generation(TX), and one for signal comparison(RX). In a metal detector there are two coils in the search head. The transmission coil sends out the signal produced from TX Arduino that we have been working on. The receiver coil picks up any signal that a peace of metal is making. There are hardware amps on both the TX/RX signals. The RX Arduino has a few jobs, compare and report the two different between signals, watching both the coils at the same time. It takes the difference and outputs it over bluetooth to an Android based phone, where MUCH more power is available for real DSP. A serial event comes into play when the use (Me), wants to change the frequency of the TX Arduino, or the shape of the wavetable. The user inputs the new data setting and they are transmitted via bluetooth to the RX Arduino. In turn the RX Arduino will send the data set to the TX Arduino. I hope this cleared up more questions then it made. For more details on the metal detector side, please see: http://www.geotech1.com/forums/showthread.php?p=119001&posted=1
|
|
|
|
|
15
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: How do I set TCNT2 for XXXXX Hz
|
on: November 18, 2010, 11:58:24 pm
|
Really, is it this simple?! byte wavetable[32] = {128, 154, 178, 201, 220, 236, 247, 254, 255, 251, 242, 228, 211, 190, 166, 141, 115, 90, 66, 45, 27, 14, 5, 1, 3, 9, 20, 36, 56, 78, 103, 128}; byte i = 0; byte delay_length = 50;
void setup() { for (byte z = 6; z <= 13; z++) { pinMode(z, OUTPUT); } }
void loop() { PORTD=wavetable[i];
i++; if (i==32) //The real question... exact same run time in both cases? { i=0; } else { i=i; }
delay(delay_length); //This may need to be an ASM `nop` } Need to do some scope testing to figure out what the speeds look like.
|
|
|
|
|