Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Networking, Protocols, and Devices / Sorted - Re: RS485 issue using SoftwareSerial() on: January 14, 2013, 07:38:23 pm
Sorted.

For some reason I commented out 
//#include <RS485_protocol.h>
and included
#include <RS485_non_blocking.h>

when both should be included.
Sometimes you just can't see the forest for the trees

Cheers
17  Using Arduino / Networking, Protocols, and Devices / Re: RS485 issue using SoftwareSerial() on: January 14, 2013, 01:27:36 pm
Straight from Nick Gammon site
http://www.gammon.com.au/forum/?id=11428
18  Using Arduino / Networking, Protocols, and Devices / RS485 issue using SoftwareSerial() on: January 14, 2013, 01:02:48 am
Hi

I have downloaded Nick Gammon code, but are having some compiling issues.
I got it down to 2 errors

Code:
//#include "WConstants.h"
#include <RS485_non_blocking.h>
//#include "RS485_protocol.h"
#include <SoftwareSerial.h>

const byte ENABLE_PIN = 4;
const byte LED_PIN = 13;

SoftwareSerial rs485(2, 3);  // receive pin, transmit pin

// callback routines
 
void fWrite (const byte what)
  {
  rs485.print (what); 
  }
 
int fAvailable ()
  {
  return rs485.available (); 
  }

int fRead ()
  {
  return rs485.read (); 
  }

void setup()
{
  rs485.begin (28800);
  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
  pinMode (LED_PIN, OUTPUT);  // built-in LED
}  // end of setup
 
byte old_level = 0;

void loop()
{

  // read potentiometer
  byte level = analogRead (0) / 4;
 
  // no change? forget it
  if (level == old_level)
    return;
     
  // assemble message
  byte msg [] = {
     1,    // device 1
     2,    // turn light on
     level // to what level
  };

  // send to slave 
  digitalWrite (ENABLE_PIN, HIGH);  // enable sending
  sendMsg (fWrite, msg, sizeof msg);
  digitalWrite (ENABLE_PIN, LOW);  // disable sending

  // receive response 
  byte buf [10];
  byte received = recvMsg (fAvailable, fRead, buf, sizeof buf);
 
  digitalWrite (LED_PIN, received == 0);  // turn on LED if error   
 
  // only send once per successful change
  if (received)
    old_level = level;

}  // end of loop

Errors are:
sketch_jan14a.cpp: In function ‘void loop()’:
sketch_jan14a.cpp:62:35: error: ‘sendMsg’ was not declared in this scope
sketch_jan14a.cpp:67:62: error: ‘recvMsg’ was not declared in this scope

But what do I replace the sendMsg with.
I have looked through the SoftwareSerial.cpp and .h files but nothing springs to mind

Thanks for any suggestions

Kim
19  Products / Arduino Due / Re: Using the Hardware Quadrature Encoder Channel on the DUE on: January 10, 2013, 01:58:00 pm
dreschel

Did you get the encoder to work ?
It appear that only 1 of the the 2 Quadrature channels pins have been connected to pins.
20  Products / Arduino Due / Re: Arduino Due - Accessing registers and inline assembly on: January 03, 2013, 04:46:47 am
I suggest using something like Ken Smith's paper is describing:

"C++ Hardware Register Access Redux"

Its a policy based design using function templates and once setup has clarity and safety.

21  Using Arduino / Programming Questions / Re: trouble with simple IF...ELSE on: December 22, 2012, 03:08:11 pm
Sweet.
Thanks for that
22  Using Arduino / Programming Questions / trouble with simple IF...ELSE on: December 22, 2012, 03:01:41 pm
I can't for the life of me work out why the code below doesn't work.
Never gets to the ELSE statement, something keeps changing the "pinstate" back to zero

Cheers
K

Code:
void BlinkLED13()
{
  // blinks LED 13
  int pinstate;      // state of the output pin

  if (pinstate == 0)
  {
    digitalWrite(ledPin, pinstate);
    pinstate = 1; 
    delay(100);
  }
  else
  {
    digitalWrite(ledPin, pinstate);
    pinstate = 0;
    delay(100);
  }

}
23  Using Arduino / Programming Questions / Re: Using i/o via an array on: December 20, 2012, 01:57:00 pm
Ha

I was so busy thinking about it, before buggering of to work, that I missed the obvious.

Cheers
24  Using Arduino / Programming Questions / Using i/o via an array on: December 20, 2012, 01:34:56 pm
I'm trying to get my head around arrays in C.

I can do the following as to assign i/o pins via an array
int pins [6] = { 3, 5, 7, 10, 12, 13 }

However, can I assign a name to a pin and then use it in the array

const int Button1 = 3;
int pins [6] = { Button1, 5, 7, 10, 12, 13 }

thanks for any clarification

K
25  Products / Arduino Due / Re: More ideas for new Arduino DUE compatible board on: December 17, 2012, 01:54:05 am
The LED on pin 13 is most useful at times, especially during debugging, so it would be wise to leave it, IMHO.
K
26  Products / Arduino Due / Re: FreeRTOS for Due, Teensy 3.0 and AVR Arduinos on: December 16, 2012, 02:51:24 pm
Thanks a bunch :-)
27  Products / Arduino Due / Quadrature encoder on: December 12, 2012, 01:16:58 am
Anyone got a Quadrature encoder up and running on the Due ?
Can you share the setup ?
The tables and the timer (TC) are somewhat bewildering to me and I cannot find any examples on Atmels website for the SAM3X chip that shows any source code

Cheers
K
28  Products / Arduino Due / Re: Due External Interrupts on: December 07, 2012, 03:32:11 pm
Might be worth to try it with a SR Latch on the input.
This way it would eliminate any input issues
29  Products / Arduino Due / Re: Due External Interrupts on: December 06, 2012, 07:41:07 pm
You properly should not do anything like serial.print inside the ISR.
Just set a flag and print elsewhere.
I think print is buffered or something as the code locks up on a mega when triggering the interrupt.

30  Products / Arduino Due / Re: Due External Interrupts on: December 05, 2012, 01:50:51 pm
On the 8bit Arduino boards I have, the firmware appears to be doing something strange at each startup, so could be tied up with that.
I will try to run your code on another board when I get home tonight.
Pages: 1 [2] 3 4 ... 6