Show Posts
Pages: [1] 2 3 ... 5
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Serial problem on: December 11, 2008, 03:29:10 pm
The AFSoftSerial has a buffer of 64 chars

I can show some , code, i havent saved it, but i think i can repoduce some simple code. Ill do that later
2  Forum 2005-2010 (read only) / Troubleshooting / Serial problem on: December 10, 2008, 10:09:33 am
Hello, im using a telit module connected to a arduino.
So far is everything fine, and using AFSoftSerial to make a extra comport
the softwareserial is connected to the telit, en the main serial is for debugging.

This works all fine, but time to time im losing a few chars, or there come strange chars out.

So i figured out that ill connect the telit to the main serial (port 0 and 1)
and using the software serial to debug (using Mini USB Adapter to get it to my computer).

now the debug works fine, but i cant get a connection to my telit whatever i do.

I used different baud rate's, switch tx/rx
i just dont get anything from the telit

How is this possible that the softwareSerial works perfect on the telit but not the hardware serial?
3  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: hack that gets the AVR device, only works for mega on: October 15, 2009, 06:40:15 am
I have recompiled the arduino with the ID in the boards.txt file

Code:
at90can128.build.mcuid=c128

works like a charm
4  Forum 2005-2010 (read only) / Bugs & Suggestions / hack that gets the AVR device, only works for mega on: October 14, 2009, 05:46:35 am
In the fileAvrdudeUploader.java,
the function: "public boolean avrdude(Collection params) throws RunnerException {"
Code:
// XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168",
    // then shove an "m" at the beginning.  won't work for attiny's, etc.
    commandDownloader.add("-pm" +
      Preferences.get("boards." + Preferences.get("board") + ".build.mcu").substring(6));
    commandDownloader.addAll(params);

This code only works for a atmega series
But if your using a other AVR, in my case at90can128
I get this error: avrdude: AVR Part "mn128" not found.

I have changed the "avrdude.conf" file the mcu id from c128 to mn128, and that works but its a very dirty hack.

Is it possible in a new release to make it support all AVR's?
Like adding in the file "boards.txt" a mcu id?
something like this:
Code:
commandDownloader.add("-p" +
      Preferences.get("boards." + Preferences.get("board") + ".build.mcuid"));
Or even nicer would be to get it out the "avrdude.conf" file
5  Forum 2005-2010 (read only) / Development / Re: Lego powerfunctions IR on: November 28, 2008, 05:57:33 pm
Oke,  ive got the code fully working now, and i made a java program to control it.



Power is ofcourse to switch it on (maybe wait a few sec till the arduino is done booting)
channel selector;
2 throttle sliders, and you can link them;
checkbox below is to turn Forward<-> backwards

arduino code: http://www.rjw.speedxs.nl/arduino/lego_ir.pde

java program: http://www.rjw.speedxs.nl/arduino/Lego Powerfunctions.rar atmthe Java program is hardcoded to COM4.
6  Forum 2005-2010 (read only) / Development / Re: Lego powerfunctions IR on: November 28, 2008, 12:13:01 pm
Oke Ive got it working now!!!

IR need to pulse ofcourse, so i used David Cuartielles code of the remote control the oscillationWrite() function to make a pulse.

Now it works like a charm, the code is not done yet, but if you put this on your arduino with a ir led on port 13 your lego 8275 bulldozer wil drive forward on a interval of 2 secs

Not bad for me *couch* first time i play with arduino.

Code:
//mode
#define COMBO_DIRECT_MODE 0x01
#define SINGLE_PIN_CONTINUOUS 0x2
#define SINGLE_PIN_TIMEOUT 0x3
#define SINGLE_OUTPUT 0x4

//PWM speed steps
#define PWM_FLT 0x0
#define PWM_FWD1 0x1
#define PWM_FWD2 0x2
#define PWM_FWD3 0x3
#define PWM_FWD4 0x4
#define PWM_FWD5 0x5
#define PWM_FWD6 0x6
#define PWM_FWD7 0x7
#define PWM_BRK 0x8
#define PWM_REV7 0x9
#define PWM_REV6 0xA
#define PWM_REV5 0xB
#define PWM_REV4 0xC
#define PWM_REV3 0xD
#define PWM_REV2 0xE
#define PWM_REV1 0xf

//speed
#define RED_FLT 0x0
#define RED_FWD 0x1
#define RED_REV 0x2
#define RED_BRK 0x3
#define BLUE_FLT 0x0
#define BLUE_FWD 0x4
#define BLUE_REV 0x8
#define BLUE_BRK 0xC


//channel
#define CH1 0x0
#define CH2 0x1
#define CH3 0x2
#define CH4 0x3

//output
#define RED 0x0
#define BLUE 0x1

int IRPin = 13;
int toggle[4] = {0,0,0,0};

void setup()
{
  pinMode(IRPin, OUTPUT);
  digitalWrite(IRPin, LOW);
  //Serial.begin(9600);
  //delay(2);
  
}

void loop()
{
  ComboMode(BLUE_REV, RED_FWD, CH1);
  delay(2000);
  
}

void pf_send(int code1, int code2)
{
  int x = 128;
  
  start_stop_bit();
  
  while (x)
  {
    oscillationWrite(IRPin, 156);
    
    if (code1 & x) //high bit
      high_pause();
    else //low bit
      low_pause();
    
    x >>= 1;  //next bit
  }
  
  x = 128;
  while (x)
  {
    oscillationWrite(IRPin, 156);
    
    if (code2 & x) // high bit
      high_pause();
    else //low bit
      low_pause();

    x >>= 1;  //next bit
  }
  
  start_stop_bit();
  delay(10);
}

void ComboMode(int blue_speed, int red_speed, int channel)
{
  int nib1, nib2, nib3, nib4, i;
  
  //set nibs
  nib1 = channel;
  nib2 = COMBO_DIRECT_MODE;
  nib3 = blue_speed | red_speed;
  nib4 = 0xf ^ nib1 ^ nib2 ^ nib3;

  for(i = 0; i < 6; i++)
  {
    message_pause(channel, i);
    pf_send(nib1 << 4 | nib2, nib3 << 4 | nib4);    
  }
}


void SingleOutput(int pwm, int output, int channel)
{
   int nib1, nib2, nib3, nib4, i;

   //set nibs
   nib1 = toggle[channel] | channel;
   nib2 = SINGLE_OUTPUT | output;
   nib3 = pwm;
   nib4 = 0xf ^ nib1 ^ nib2 ^ nib3;
  
   for(i = 0; i < 6; i++)
   {
     message_pause(channel, i);
     pf_send(nib1 << 4 | nib2, nib3 << 4 | nib4);    
   }
  
   if(toggle[channel] == 0)
     toggle[channel] = 8;
   else
     toggle[channel] = 0;
}

void start_pause()
{
  delayMicroseconds(1014);
}

void high_pause()
{
  delayMicroseconds(546);
}

void low_pause()
{
  delayMicroseconds(260);
}

void tx_pause()
{
  delayMicroseconds(156);
}

void message_pause(int channel, int count)
{
  unsigned char a = 0;
  
  if(count == 0)
    a = 4 - channel + 1;
  else if(count == 1 || count == 2)
    a = 5;
  else if(count == 3 || count == 4)
    a = 5 + (channel + 1) * 2;
      
  delayMicroseconds(a * 77);
}


void start_stop_bit()
{
  oscillationWrite(IRPin, 156);  
  //digitalWrite(IRPin, HIGH);
  //tx_pause();
  //digitalWrite(IRPin, LOW);
  start_pause();
}

void oscillationWrite(int pin, int time) {
  for(int i = 0; i <= time/26; i++) {
    digitalWrite(pin, HIGH);
    delayMicroseconds(13);
    digitalWrite(pin, LOW);
    delayMicroseconds(13);
  }
}
7  Forum 2005-2010 (read only) / Development / Re: Lego powerfunctions IR on: November 27, 2008, 05:01:24 pm
Ive made some starting code, but its not working.
I used most of the code from the RCX brick because its also C code

Code:
//mode
#define COMBO_DIRECT_MODE 0x01
#define SINGLE_PIN_CONTINUOUS 0x2
#define SINGLE_PIN_TIMEOUT 0x3
#define SINGLE_OUTPUT 0x4

//PWM speed steps
#define PWM_FLT 0x0
#define PWM_FWD1 0x1
#define PWM_FWD2 0x2
#define PWM_FWD3 0x3
#define PWM_FWD4 0x4
#define PWM_FWD5 0x5
#define PWM_FWD6 0x6
#define PWM_FWD7 0x7
#define PWM_BRK 0x8
#define PWM_REV7 0x9
#define PWM_REV6 0xA
#define PWM_REV5 0xB
#define PWM_REV4 0xC
#define PWM_REV3 0xD
#define PWM_REV2 0xE
#define PWM_REV1 0xf

//channel
#define CH1 0x0
#define CH2 0x1
#define CH3 0x2
#define CH4 0x3

//output
#define RED 0x0
#define BLUE 0x1

int IRPin = 13;
int toggle[4] = {0,0,0,0};

void setup()
{
  pinMode(IRPin, OUTPUT);
  //Serial.begin(9600);
  //delay(2);
  
}

void loop()
{
  SingleOutput(PWM_FWD7, RED, CH1);
  //delay(2000);
  
}

void pf_send(int code1, int code2)
{
  int x = 128;
  
  start_stop_bit();
  
  while (x)
  {
    digitalWrite(IRPin, HIGH);
    tx_pause();
    digitalWrite(IRPin, LOW);
    
    if (code1 & x) //high bit
      high_pause();
    else //low bit
      low_pause();
    
    x >>= 1;  //next bit
  }
  
  x = 128;
  while (x)
  {
    digitalWrite(IRPin, HIGH);
    tx_pause();
    digitalWrite(IRPin, LOW);
    
    if (code2 & x) // high bit
      high_pause();
    else //low bit
      low_pause();

    x >>= 1;  //next bit
  }
  delay(10);
}

void SingleOutput(int pwm, int output, int channel)
{
   int nib1, nib2, nib3, nib4, i;

   //set nibs
   nib1 = toggle[channel] | channel;
   nib2 = SINGLE_OUTPUT | output;
   nib3 = pwm;
   nib4 = 0xf ^ nib1 ^ nib2 ^ nib3;
  
   for(i = 0; i < 6; i++)
   {
     message_pause(channel, i);
     pf_send(nib1 << 4 | nib2, nib3 << 4 | nib4);    
   }
  
   if(toggle[channel] == 0)
     toggle[channel] = 8;
   else
     toggle[channel] = 0;
}

void start_pause()
{
  delayMicroseconds(1014);
}

void high_pause()
{
  delayMicroseconds(546);
}

void low_pause()
{
  delayMicroseconds(260);
}

void tx_pause()
{
  delayMicroseconds(156);
}

void message_pause(int channel, int count)
{
  unsigned char a = 0;
  
  if(count == 0)
    a = 4 - channel + 1;
  else if(count == 1 || count == 2)
    a = 5;
  else if(count == 3 || count == 4)
    a = 5 + (channel + 1) * 2;
      
  delayMicroseconds(a * 77);
}


void start_stop_bit()
{
 digitalWrite(IRPin, HIGH);
 tx_pause();
 digitalWrite(IRPin, LOW);
 start_pause();
}


The RCX code used some sort of for loop delay, i use delayMicroseconds.

Can this be the problem?
Can someone help me?
8  Forum 2005-2010 (read only) / Development / Lego powerfunctions IR on: November 26, 2008, 05:23:39 pm
Ive had a idea to use a irduino as a IR transmitter to control the lego powerfunction receiver.

But I am a total nooby in this, ive done some research and found the protocol document for the lego transmitter:
http://www.philohome.com/pf/LEGO_Power_Functions_RC.pdf

And here is some example code of someone who made his lego RCX brick to do what i want with the arduino:
http://www.fial.com/bob/lego/PowerFunctions.zip

You can do more things then the lego transmitter, like PWM!

Can someone help me out, or put me one the right track so i can make it?
9  Forum 2005-2010 (read only) / Development / Re: Bootloader that fits in 256 words on: December 02, 2009, 08:34:58 pm
Oke, ive got it working at 8mhz now, i had a wrong fuse.

It works like a charm! very nice.

For the arduino users, set in the make file the next on 0:
CODE_CHECK
BL_CHECK
WDT_CHECK

If one of these are set 1, you cant re-upload a new sketch.
10  Forum 2005-2010 (read only) / Development / Re: Bootloader that fits in 256 words on: December 02, 2009, 06:50:43 pm
When im running the atmega8 on 16mhz it works, but when I use the internal crystal on 8MHz it doesn't work any more.

I have changed the make file from 16mhz to 8mhz, I also lower the baud rate, nothing works.
Led13 blinks very fast.

And for the fuses, how many words do i have to set de boot flash section? 256 words?
11  Forum 2005-2010 (read only) / Troubleshooting / Re: Infrared Reciever problem. on: August 27, 2009, 06:37:15 am
Yes your right, that what i mean, but still timing is very precise, often as low as 300us, so still using a interrupt suits best. Using a whilelus to wait for IR, well then you cant do anything else.

I have interrupt based code, so if your interested i can post it.
(its for lego protocol, you have to change the timing for a other remote control)

12  Forum 2005-2010 (read only) / Troubleshooting / Re: Infrared Reciever problem. on: August 27, 2009, 06:24:01 am
Hooking up a IR-receiver on a analog port will not work.

Your IR-PIN will go LOW if its receives a IR-signal. Based on the timing, and protocol you can read out bit's

Best way to do this, is interrupt driven, as IR is 36/38Khz you don't want to miss a bit.
13  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino killed by AC then reborn on: July 05, 2009, 04:02:55 am
the caps are fine, 9ac doesn't damage caps when there is a protection diode
14  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino killed by AC then reborn on: July 03, 2009, 04:28:38 pm
If it uploads sketches again, then everything is oke.

I as far I know, nothing is damaged, the diode has protected the board for the negative voltage. That why the leds blinks.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: Powering Arduino Pro Issues on: June 21, 2009, 06:53:38 pm
Thats a cap with the burn mark You can replace it than it "should"work fine again.

Your statements are true.

If you power directly 5v you can get alot more ma, up to 1 amp.
But it has to be a regulated power supply, USB or a other adapter.
I recommend to make a own small one, with a 7805 regulator like this: http://www.circuitsonline.net/img/000025.gif
(the 1000uf cap can be a 100uf) You can supply it with your 9v adapter.
Pages: [1] 2 3 ... 5