Show Posts
Pages: [1] 2 3 ... 5
1  Products / Arduino Yún / Re: Yun serial question on: April 16, 2014, 06:30:08 pm
I'm not sure I understand your reply.  Perhaps if I rephrase the question...

I am trying to bridge from my PC to a vending machine with MDB protocol (9 bit parity).  Everyone i've found who has succeeded at this has found hardware serial is the only way to make it work.  I thought a Yun would be convenient - use the hardware serial to talk to the vending machine, and some other serial to talk to the rest of the world.  I thought talking to Yun's linux kernel and then from there to the rest of the network would be pretty straightforward.

Now that I think about it, an UNO with an ethernet shield might also do the trick.

Which method would you suggest?
2  Products / Arduino Yún / Yun serial question on: April 16, 2014, 02:32:18 pm
I'm using the hardware serial in my Arduino to talk to another device.
I need debug messages from the Arduino.  Normally I would Serial.print().
If I use a Yun is there some other way to talk to the linux-side of the board and get my messages out?

Thanks!
3  Using Arduino / Programming Questions / Re: How do I set the frequency on the mega timer3? on: January 06, 2014, 02:26:44 pm
MarkT - I didn't know what the values of CS3* were, so I didn't take the chance.  I'll do it your way.

Have you tried to run it?  Do your results match mine?  I'd love a sanity check to confirm it's not just me getting bad numbers, please.
4  Using Arduino / Programming Questions / How do I set the frequency on the mega timer3? on: January 05, 2014, 04:29:00 pm
I think I've almost got it.  The callback is definitely happening.  The prescalers reported when VERBOSE is defined look good. ...but the frequency actually seen is the same, every time, regardless of the value I ask for.  I think it's the CTC but I'm just not sure.

Please: what did I miss?

Thank you!

Code:
ISR(TIMER3_COMPA_vect) {}


void timer_set_frequency(long desired_freq_hz) {
  if(old_feed_rate==desired_freq_hz) return;
  old_feed_rate=desired_freq_hz;

  // ** find a valid prescaler **
  // CPU frequency for Arduino is 16Mhz.  CLOCK_FREQ=16000000
  int prescaler_index=-1;
  int prescalers[] = {1,8,64,256,1024};
  // maximum timer counter value (256 for 8bit, 65536 for 16bit timer)
  long counter_value;
  do {
    ++prescaler_index;
    //  Divide CPU frequency through the choosen prescaler (16000000 / 256 = 62500)
    counter_value = CLOCK_FREQ / prescalers[prescaler_index];
    //  Divide result through the desired frequency (62500 / 2Hz = 31250)
    counter_value /= desired_freq_hz;
    //  Verify counter_value < maximum timer. if fail, choose bigger prescaler.
  } while(counter_value >= MAX_COUNTER && prescaler_index < TIMER_PRESCALER_COUNT );

  if( prescaler_index == TIMER_PRESCALER_COUNT ) {
    // @TODO: Serial.print() from inside the timer interrupt will probably crash the board.
    Serial.println(F("Timer could not be set: Desired frequency out of bounds."));
    return;
  }

  // prescalers is zero-indexed, we need one-indexed.
  ++prescaler_index;

#ifdef VERBOSE
  Serial.print(F("desired_freq_hz="));  Serial.println(desired_freq_hz);
  Serial.print(F("counter_value="));  Serial.println(counter_value);
  Serial.print(F(" prescaler_index="));  Serial.print(prescaler_index);
  Serial.print(F(" > "));  Serial.print(  ((prescaler_index&0x1)   ));
  Serial.print(F("/"));    Serial.print(  ((prescaler_index&0x2)>>1));
  Serial.print(F("/"));    Serial.println(((prescaler_index&0x4)>>2));
#endif

  // ** set the timer frequency **

  noInterrupts();  // disable global interrupts
  TCNT3  = 0;  // set the overflow clock to 0
  OCR3A = counter_value - 1;  // set compare match register to desired timer count
  TCCR3A = (1 << WGM32);  // turn on CTC mode
  // Set bits for prescaler
  TCCR3B = ( (( prescaler_index&0x1 )   ) << CS30);
  TCCR3B |= ( (( prescaler_index&0x2 )>>1) << CS31);
  TCCR3B |= ( (( prescaler_index&0x4 )>>2) << CS32);
  TIMSK3 |= (1 << OCIE3A);  // enable timer compare interrupt
  interrupts();  // enable global interrupts
}
5  Using Arduino / Interfacing w/ Software on the Computer / Persistent arduino/pi connection - how?! on: December 10, 2013, 07:02:04 pm
Challenge: I need a pi to talk to an arduino without resetting the arduino. I have shields on the arduino that prevent me from using a resistor to bridge 5v and gnd.  The shield also blocks my access to RX/TX pins so I can't go use a hardware serial connection with a voltage divider to the pi GPIO pins. Using a daemon on the pi I want to open a connection to the arduino and then keep it open, passing messages back and forth between the arduino and my program.

Method: On the pi side I've got PEAR installed with System_Daemon and php_serial.class.php. I use a mysql db as a 2-way buffer.

Problem: The daemon doesn't appear to be receiving anything from the arduino.  I know the daemon can read and write with mysql.

My daemon code so far: http://pastebin.com/hM9dJNsE

The error messages:

      err: No stty availible, unable to run. [l:58]
  warning: Specified serial port is not valid [l:141]
  warning: Unable to set the baud rate : the device is either not set or opened [l:234]
  warning: Unable to set parity : the device is either not set or opened [l:288]
  warning: Unable to set length of a character : the device is either not set or opened [l:336]
  warning: Unable to set the length of a stop bit : the device is either not set or opened [l:377]
  warning: Unable to set flow control mode : the device is either not set or opened [l:422]
  warning: The device must be set before to be open [l:167]

stty definitely exists on the pi and can be run as user root or pi, so I don't know why I'm getting error #1dd.

Why is this happening? Is there a better way? Has anyone got a working example?

Thank you!
6  Using Arduino / Programming Questions / Arduino timer1 on MEGA resetting every 4s. What did I do wrong? on: November 03, 2013, 08:15:03 pm
Code: http://pastebin.com/q1vUPMkR

I followed two nearly identical tutorials, one of which is linked in the code.  My board outputs '2hz' and then resets.  I expect it to go through the entire test suite.  What am I doing wrong?  Did I somehow accidentally activate the watchdog?

Thank you!
7  Using Arduino / Installation & Troubleshooting / Yun questions on: September 30, 2013, 03:37:27 pm
can the Yun run a LAMP stack?

can I connect to the Yun Linux via SSH and update the arduino sketch with inotools?

can I send messages from linux to arduino without resetting the arduino?  When I try this from rpi to UNO I need a daemon that keeps the serial connection open and passes messages back and forth using MYSQL as a bi-directional buffer.

Thank you!
8  Using Arduino / Project Guidance / Re: Raspberry Pi + LAMP stack talking to arduino UNO or Leonardo on: July 05, 2013, 01:30:13 pm
Yes, those are all good points and should be part of the spec.  Thank you for catching my oversight!
9  Using Arduino / Project Guidance / Re: Raspberry Pi + LAMP stack talking to arduino UNO or Leonardo on: July 05, 2013, 12:03:29 pm
Well... thanks for bumping the thread.
10  Using Arduino / Project Guidance / Re: Raspberry Pi + LAMP stack talking to arduino UNO or Leonardo on: July 05, 2013, 10:19:30 am
Well not with THAT attitude.

I'm thinking some kind of daemon running on the pi that acts as a go-between, keeping the connection open and queueing messages in both directions.  I've never written a daemon in linux before so I'm not sure where to start.  Kill the daemon when appropriate to perform an upgrade, then restart to continue normal operations.
11  Using Arduino / Project Guidance / Raspberry Pi + LAMP stack talking to arduino UNO or Leonardo on: July 04, 2013, 04:10:43 pm
Goal
I want to build the next UI for my robot in a website so that I don't have to translate it for other devices - anything with a browser should work.  It will also mean that the pi can use a cron() to update itself and upload new sketches to the arduino.

Status
I can upload sketches to the arduino UNO with inotool.  I can't with Leonardo because I get out_of_sync or programmer_not_responding.
I can open a serial connection.
I have a pi running a LAMP stack with a website.
When I click a button on the website I can send data to the arduino.
When I click a button on the website I want to see a log of messages sent back from the arduino.

Challenge
Every time I open a serial connection the UNO resets.
Every time I try to open a serial connection the Leo gives an out_of_sync error.

Question
How do I maintain a connection so that I the arduino doesn't reset every time AND still be able to upload sketches without hitting the reset button?

Thank you!
12  Using Arduino / Interfacing w/ Software on the Computer / how to create a persistent USB serial connection between raspberry pi & arduino? on: June 23, 2013, 09:32:26 pm
I have a raspberry pi connected via USB to an arduino.  I can build and upload from the pi using inotool. 
I want a mini server to connect to the arduino, maintain the connection, and pass strings back and forth.
I want to be able to send instructions to the arduino from php.  I'm guessing I need to pipe using exec()?
I want to be able to get messages back to PHP from the mini server.  At the speed I'm going the time delay is not a big deal.

I've found many tutorials about listening to serial in linux.  I haven't found any yet about sending.

Can you help me, please?
13  Topics / Device Hacking / Re: UNO as a HID compliant joystick? on: May 07, 2013, 01:22:53 pm
Total cost UNO + USB Host Shield > Leonardo.  Decision made.

Thanks!
14  Topics / Device Hacking / UNO as a HID compliant joystick? on: May 07, 2013, 12:14:19 pm
Hi!

I want my UNO to show up as a HID compliant joystick.  I've already written the sketch to run on the microcontroller.  I don't have the bootloader right.  I've been told DFU can do it, but then people in arduino said "no, buy extra hardware to do the job right."  I'd really really like to do the job without buying extra hardware.  Please: Is there a way?

Thank you!
15  Topics / Device Hacking / Re: Have you made a joystick from an Arduino? I need your expertise, please. on: May 07, 2013, 11:31:10 am
"making it possible to build USB hardware with almost any AVR® microcontroller, not requiring any additional chip."

Thanks for the quick reply.  Unfortunately this doesn't meet my needs.
I don't want to build any extra hardware.  I don't want to buy some wierd programming device.
I'm led to believe there's a way to change the bootloader so that my existing sketch stays on the chip and it will show up as a joystick.  It's supposed to use the existing USB port.

Have you got a way to do that, please?
Pages: [1] 2 3 ... 5