Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / Re: Problems with AT commands to Bluetooth HC-06 on: November 23, 2013, 01:04:49 am
Pito,

My understanding was that 1000 ms was the maximum delay between characters in a command, not between commands, but you got me thinking about it, so I tried delay(200), which did not work; then I tried delay(2000) between the commands, and that WORKED! Apparently 1000 ms was just cutting it too close...

Trying different things, I noticed another quirk: trying to change the name from "Test1234" to something else with the following code (Mega2560, HC-06 TX attached to D10, RX to D11):

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
   mySerial.begin(57600);
   mySerial.print("AT+NAME123456789012345");
}

void loop() {
}

... failed. However, one character less - mySerial.print("AT+NAME12345678901234") - worked fine! But when I changed the Bluetooth UART baud rate to 9600, I was able to set names up to 20 characters without problems. I would now dare to guess that the cause is the deviation of both the Bluetooth and Arduino UART baud rates from nominal values (and from each other), and that higher speeds may require hardware flow control. The problems are then going to be more pronounced with Tiny MCUs running at lower speeds and with on-chip oscillators.
2  Using Arduino / Networking, Protocols, and Devices / Problems with AT commands to Bluetooth HC-06 on: November 22, 2013, 03:17:47 pm
Anyone have HC-06s not responding to AT commands issued from a sketch (see the code below)?

I have a bunch of devices, all with three things in common:
   - ATtiny processor (different ones, but all with serial port, like 2313, 4313, 87...),
   - HC-06 bluetooth module connected to Tiny's RX and TX pins, and
   - ISP connector for programming.

 The idea was to customize the Bluetooth device name, pairing PIN and UART communication speed by uploading a sketch (using my Mega2560 and "Arduino as ISP" example code) :

Code:
void setup() {
   Serial.begin(9600);
   delay(1000);
   Serial.print("AT+NAMEBT 001");
   delay(1000);
   Serial.print("AT+PIN4321");
   delay(1000);
   Serial.print("AT+BAUD7");
}

void loop() {
}

Then' I'd "File => Upload Using Programmer" the code that should actually run on the device.

Two identical (at least the intention was) devices with Attiny 4313 and HC-06. Upload the intended code that the device is intended for; both work. Now upload above BT config code, then regular running code again. The first device successfully changes name, pin and baud rate. The second does nothing, and HC-06 still has original "HC-06" name and still operates at 9600 bps.

Now things get weird one step further: uploading BT config code to change back the first HC-06's name, pin and baud rate - does nothing (I did remember to change the speed in Serial.begin). Now I have two Bluetooth modules that do not respond to AT commands... Could it be a timing issue with "Serial.print" commands?

(the baud rate in Serial.begin was correct, and the Bluetooth modules were not paired to anything - the LEDs on PIO1 are blinking; names and PINs checked by searching for Bluetooth devices using Amarino on Android phone)
3  Using Arduino / Programming Questions / What is max frequency for tone() on: June 17, 2013, 07:23:52 pm
The reference does not mention it, and I don't have scope at hand, so:

Does anyone know what is the maximum frequency that tone() can output? I'd expect it to be hardware/clock dependent...
4  Using Arduino / Sensors / Re: Data Visualization on: June 05, 2013, 02:20:19 pm
Here is the project that does exactly what you are looking for:

http://www.dustynrobots.com/news/seeing-sensors-how-to-visualize-and-save-arduino-sensed-data/

It just works. Two things to watch for:
- Make sure that Serial.begin (line 5) in the Arduino code uses the data rate that matches the Bluetooth module setting.
- The Processing code (line 11) portName = Serial.list()
  • needs to index to the port that has the Bluetooth dongle attached to; on my computer, on initializing, the processing code reports
  • com1, [1] com2, [2] com5; to plot the data that comes through bluetooth (com5 on my computer), I'll have in line 11: portName = Serial.list()[2]
5  Using Arduino / Sensors / Re: Data Visualization on: May 26, 2013, 11:51:58 pm
The sensor should be connected to an analog port; there is only one wire (plus ground, of course) that goes from the sensor to arduino. The sample code from the Advancer simply reads the voltage on that wire (assumes the wire is connected to A6), and sends the value to the Arduino's serial port. It is totally up to you what to do with the data. If you open the serial monitor on the PC attached to the Arduino, you'll see numbers, and a lot of them - one every 10 milliseconds. Of course, if you connect a BlueTooth module to Arduino, you can get those numbers over to a device that pairs up to the Arduino's BT. The thing is, those are still just numbers, one every 10 ms. Visualization is another animal alltogether. If you are on a PC, LabView or Matlab for example support data visualization in just a few steps. On an Android device, you may try MIT's AppInventor (online Android app development environment, graphical interface, requires no programming knowledge, simulates the phone too, very nice. In just a few minutes you can create an app that plays a tone corresponding to the number received over the BT smiley )
6  Using Arduino / Microcontrollers / Re: Problem with hardware serial on ATtiny 4313 on: May 26, 2013, 10:41:58 pm
Works! Thanks a lot.
7  Using Arduino / Microcontrollers / Re: Problem with hardware serial on ATtiny 4313 on: May 25, 2013, 11:01:22 am
Hopefully I am not complicating the issue further, but with 4313 at 8 MHz (lfuse 0x64 => 0xE4, right?), I have a different problem. Watchdog behaves strange. The code I showed in the other post, which should blink a LED, works OK at 1 MHz, but at 8 MHz resets the MCU after reaching the ISR for the first time - the LED just briefly blinks every 2 s, due to being turned on in setup() ... (this has nothing to do with Serial at the moment)

Code:
byte LED = 13;
boolean LEDon = true;

void setup()
{
   pinMode (LED, OUTPUT);
   digitalWrite (LED, LEDon);

   // Set up and turn on the watchdog timer.
   MCUSR &= ~(1<<WDRF);               // Clear the watchdog reset flag
   WDTCSR |= (1<<WDCE) | (1<<WDE);    // Set WDE and WDCE - must be done in one operation; writing 1 to WDE starts the timed sequence
   WDTCSR = B00000111;                // Set the watchdog timeout prescaller to 2 s; must be done within 4 cycles from writing 1 to WDE
   WDTCSR |= _BV(WDIE);               // Enable the watchdog timer interrupt.
}



ISR(WDT_OVERFLOW_vect)   //  Watchdog Interrupt Service.
{
   LEDon = !LEDon;
   digitalWrite (LED, LEDon);
   //bitSet(WDTCSR,WDIE);
}



void loop()
{
}
8  Using Arduino / Microcontrollers / Problem with hardware serial on ATtiny 4313 on: May 25, 2013, 01:59:30 am
I have a problem with ATtiny: the blink code seems to slow down when a serial device is connected (physical pins 2 and 3, RX & TX) and the Serial.begin (9600); is in the setup(). In fact, here is the code:
Code:
int led = 13;

void setup() {               
  Serial.begin (9600);
  pinMode(led, OUTPUT);     
}

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

The LED blinks about 3 times slower than expected. But If I either disconnect the serial device, or leave it connected but comment out the Serial.begin, then the blinking rate is OK. If that matters, the ATtiny 4313 is running on two AAA batteries at 1 MHz (8 MHz internal oscillator, internally divided). I don't have this problem with Nano or Pro Mini. I have seen posts related to problems with software serial on tinys, and with serial speeds above 9600 at 1 MHz. None of that seems to apply here, does it?
9  Using Arduino / Microcontrollers / Re: INPUT_PULLUP compiling problem with ATtiny4313 on: May 24, 2013, 04:01:02 pm
That's it! Thanks hiduino. And thanks Coding for the tiny cores update!
10  Using Arduino / Microcontrollers / INPUT_PULLUP compiling problem with ATtiny4313 on: May 23, 2013, 05:03:13 pm
I have run into a problem trying to declare a pin as INPUT_PULLUP - the following compiles fine on Nano or Pro Mini, but throws 'INPUT_PULLUP' was not declared in this scope when compiled for ATtiny 4313:

Code:
pinMode (4, INPUT_PULLUP)

Other modes (INPUT, OUTPUT) compile fine. Trying pinMode (4, 2) gets the code compiled, but the code does not seem to work properly. Looking at the datasheet, ATtiny 4313 seems to have the pull-up resistors the same way the 328p does...

I am using Arduino IDE 1.0.4 with avr-gcc updated from WinAVR2010, and with ATtiny cores from Arduino-Tiny
11  Using Arduino / Microcontrollers / Re: Problem using watchdog timer on Attiny4313 on: May 20, 2013, 11:04:27 am
That was the problem - renamed vector. Now it works for me, too. Thanks HiDuino! (Took me a few days to gain control over burning fuses through ISP)

iotn4313  that comes with WinAVR20100110 has named registers differently from both the chip datasheet and from the so-far used nomenclature for other MCUs, 328p most notably; PCINT_A/B/D instead of PCINT0/1/2, WDCR-WDCSR, EIFR-GIFRand such... Extra bits in come registers - PCIE5, PCIF5 in GIMSK and GIFR... Some possible typos - BPDSE/BODSE... The iotn4313.h remains the same in avr-gcc 4.8, which makes me wonder about my view of the datasheet - i/o header relationship. I'll try to get in touch with gcc avr development crew to gain the insight.

I now have a problem turning the watchdog off on either the 4313 or the 328p, but I'll start a separate thread on the issue, as soon as I put a sample code together.

EDIT: Never mind the note on having problem turning the WDT off - the sample code from the datasheet works fine.
12  Community / Website and Forum / Re: Explorer 9, tokens and arduino.cc on: May 20, 2013, 09:54:01 am
Something related to Internet Explorer is definitely broken. I am using IE10 on Win 7 x64, and since a few days ago I have the same problem as Tom Caprenter described above - I can browse forums fine anonimously, but if I log in - then I get only a blank page. Two computers at home exhibit exactly the same behavior, and I am not aware of any other web site or forum with this problem.

I have installed Chrome to post this message and to reply to folks who have responded to my questions. Chrome accesses the Forum fine so far, but I'd go back to IE if I could.
13  Using Arduino / Microcontrollers / Problem using watchdog timer on Attiny4313 on: May 16, 2013, 12:10:30 pm
The following code works on Nano and Pro Mini, but not on bare-bones Attiny4313 with LED attached to pin 16 (D13). Can anyone see why? The LED on 4313 comes on and never turns off. Can anyone try it on any other tiny? I should mention that the Samples => Blink code works fine on 4313.

The code  below that I have the problem with is essentially "blink", except that the delay has been replaced by the watchdog timer, which toggles the state of the LED on every time-out, when the interrupt service routine is called.

To make the code work across the MCUs, I have renamed the MCUR to MCUSR and WDTCR to WDTCSR in iotn4313.h I hope that did not affect the functionality...

Code:
byte LED = 13;
boolean LEDon = true;

void setup()
{
   pinMode (LED, OUTPUT);
   digitalWrite (LED, LEDon);

   // Set up and turn on the watchdog timer.
   MCUSR &= ~(1<<WDRF);               // Clear the watchdog reset flag
   WDTCSR |= (1<<WDCE) | (1<<WDE);    // Set WDE and WDCE - must be done in one operation; writing 1 to WDE starts the timed sequence
   WDTCSR = B00000110;                // Set the watchdog timeout prescaler to 1 s; must be done within 4 cycles from writing 1 to WDE
   WDTCSR |= _BV(WDIE);               // Enable the watchdog timer interrupt.
}



ISR(WDT_vect)   //  Watchdog Interrupt Service.
{
   LEDon = !LEDon;
   digitalWrite (LED, LEDon);
}



void loop()
{
}

With this code the LED on Nano or on Pro Mini blinks at 1 s rate, but on Attiny4313 it comes and stays on, never blinking.

I am using Arduino IDE 1.0.4 with WinAVR updated to the 20100110 (gcc-avr 4.3.3).
14  Community / Exhibition / Gallery / Re: Low power consumption (0.1 uA) but wake up on keypad press on: May 11, 2013, 01:20:56 pm
Thanks John!

The ATtiny4313 seems to be implemented in the most recent WinAVR (2010-01-10) - not the one that comes with Arduino, but the latest in SourceForge. io.h does contain

Code:
#elif defined (__AVR_ATtiny4313__)
#  include <avr/iotn4313.h>

and there is iotn3413.h The registers seem there, just some (vaguely straightforward) footwork needed to modify Nick's code and reference chip-appropriate registers.

Atmel has published app notes on migration from 2313 to 4313 here: http://www.atmel.com/Images/doc8283.pdf. From the first brief reading it seems straightforward, but there are a few things I don't completely understand, like brown-out register bits 0 and 1: the Atmel papers refer to them as BODSE and BODS, and AVR io file has them as BPDS and BPDSE. Typo or my superficial understanding?
15  Community / Exhibition / Gallery / Re: Low power consumption (0.1 uA) but wake up on keypad press on: May 11, 2013, 01:16:11 am
Hey Nick,

After running your sleep code successfully on Pro Mini and Nano boards, I endeavored into ATtiny-based solution (4313 in particular). The code won't compile, complaining about WDTCSR, PCIFR, PCIF0, ..., BODS, BODSE not declared. Do you know where are these declared, so I can try updating for ATtiny 4313?
Pages: [1] 2