Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: PWM to 50 hz on: February 24, 2013, 03:48:05 pm
Thanks alot for all the help. I will look in the servo library and try to use timer1.
2  Using Arduino / Programming Questions / Re: PWM to 50 hz on: February 21, 2013, 07:31:07 am
You want to pay special attention to this section of the :
Varying the timer top limit: fast PWM on this page
http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
This is probably the most confusing configuration you'll run into.  It's not very intuitive because it looks like you will be toggling OC2A (Pin 11), but you really toggle OC2B (Pin 3).  This is because you hijack the OCR2A register to set the TOP limit so it can't possibly set a duty cycle now.  The duty cycle is set by OCR2B and consequently it toggles OC2B (Pin 3).  This is all necessary because you want to use a "non standard" PWM frequency.
Code:
 pinMode(3, OUTPUT);
  pinMode(11, OUTPUT);
  TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS22)| _BV(CS21)| _BV(CS20);           //
  OCR2A = 156;
  OCR2B = 4;

This should give you a 50.1 Hz update rate with a .512mS pulse width on Pin 3.  I haven't tested it, but I think it's right.

EDIT:  I tested it on the scope and it works.  Pin 11 has a 25Hz 50% duty cycle waveform on it.


Thanks alot! That works great. To change the pulse width i edit the output compare register b, OCR2B = 4 gives me 510us width. When i change the OCR2B value to 20 i get a 2.560ms width. Between 10 and 11 the value is 1.280ms and 1.410ms, is it possible to get a value inbetween those two? like 1.300?

Thanks in advance!
3  Using Arduino / Programming Questions / Re: PWM to 50 hz on: February 20, 2013, 01:54:03 pm
I edited my post, i ment pulsewidth and not bandwidth. I dont want to use the arduino servo library. I want to write to the registers myself..
4  Using Arduino / Programming Questions / PWM to 50 hz on: February 20, 2013, 09:03:28 am
Hello!

How do i set one of the PWM port to 50hz with a 0.5ms pulse width?

So far i got this:
Code:
 pinMode(11, OUTPUT);
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM20);
  TCCR2B = TCCR2B & 0b11111000 | 0x07;
  OCR2A = 180;
  OCR2B = 50;

This code generates a 30.6hz signal with 22.8ms pulse width.

http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
http://playground.arduino.cc/Main/TimerPWMCheatsheet

Thanks in advance
5  Using Arduino / Networking, Protocols, and Devices / Re: Connecting two arduinos using bluetooth (JY-MCU) on: February 19, 2013, 07:14:56 am
Thats real interesting. 4gbp is real cheap and the backpane is not really necessary. Do you have any experience about the pairing? If the slave and  the master is setup with the same name and password will it autoconnect on startup or do you have to program your arduino to connect to a specific mac adress?

 
6  Using Arduino / Networking, Protocols, and Devices / Re: Connecting two arduinos using bluetooth (JY-MCU) on: February 19, 2013, 04:30:37 am
smiley Alright, lets say that I succeed to reflash my bluetooths, make one master and one slave. What is the next step? How do i pair them together? Is it by a AT command or is it done by using arduino code?

Thanks in advance!
7  Using Arduino / Networking, Protocols, and Devices / Re: Connecting two arduinos using bluetooth (JY-MCU) on: February 18, 2013, 09:55:51 am
Hi!

Yeah, ive been reading about the JY-MCU and it comes with diffrent versions. The one i have is Linvor 1.5 firmware and the AT commands for it is basically change device name, password, baud. More about that in this post:

http://byron76.blogspot.se/2011/09/one-board-several-firmwares.html

So what i need is to upgrade my firmware to Linvor 1.6 who comes with more AT commands so i can set my bluetooth devices to master/slave
8  Using Arduino / Networking, Protocols, and Devices / Connecting two arduinos using bluetooth (JY-MCU) on: February 18, 2013, 07:11:36 am
Hello!

Im trying to connect two arduinos using bluetooth but i have no idea how to accomplish this. So far i've made an android application that can communicate with my arduino application.

This is the arduino code:

Code:
/* Include the software serial port library */
#include <SoftwareSerial.h>
char incomingByte;  // incoming data
int LED = 8;      // LED pin
int tx = 2;       // TX pin
int rx = 3;       // RX pin


SoftwareSerial BluetoothSerial(tx, rx);

void setup() {
  Serial.begin(9600); // initialization
  pinMode(LED, OUTPUT);
  BluetoothSerial.begin(9600);
  Serial.println("Press 1 to LED ON or 0 to LED OFF...");
 
}
 
void loop() {
  if (BluetoothSerial.available()){
    Serial.println("asd");
    digitalWrite(LED, HIGH);

    incomingByte = BluetoothSerial.read();
   
    Serial.println((char)incomingByte);
    //Serial.println(BluetoothSerial.read());
    if(incomingByte == '0') {
       digitalWrite(LED, LOW);  // if 1, switch LED Off
       Serial.println("LED OFF. Press 1 to LED ON!");  // print message
    }
    if(incomingByte == '1') {
       digitalWrite(LED, HIGH); // if 0, switch LED on
       Serial.println("LED ON. Press 0 to LED OFF!");
    }
  }
}

I got two Arduino UNOs and two JY-MCU bluetooth modules.

Is there a way to send a message to one arduino and then receive the message on the other UNO and for example, light a LED?

Thanks in advance!
9  Using Arduino / Networking, Protocols, and Devices / Re: Connect two arduinos with bluetooth on: December 25, 2012, 04:20:55 pm
Awesome thanks! Just bought 2x. What bluetooth library do you recomend?

//H
10  Using Arduino / Networking, Protocols, and Devices / Connect two arduinos with bluetooth on: December 25, 2012, 09:44:21 am
Hello!

I got two Arduino Unos and i want to send data between them via bluetooth.

I've never used bluetooth before so i have no idea what to buy.

I would like the modules to have pins so i can stick them to a protoboard.

So.. question is.. can anyone link (from ebay) two Bluetooths that can communicate with each other and that cost around 1-20 dollars apiece?

Thanks in advance!
//H
Pages: [1]