Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Efficient Way of Sending Data via Serial on: August 27, 2014, 01:31:08 pm
Hello,

I am trying to establish a method of sending data to my PC (via serial) efficiently.  The application includes a complex control system and various sensors - so continuously polling may not be recommended.

I understand that there is a buffer associated with the serial port - and I know that in Atmel Studio you can program the buffer to initiate an interrupt in order to ask for the next byte of data in order to be sent. This, in my opinion, is the best way of doing it because it does't interrupt the rest of your code. I do not know how to implement and I come here for help and other suggestions.

For now I do:

Code:
if (millis() % 100  == 0) {
    Serial.println(data);
  }

But at faster rates the control system becomes unstable and data packets are never sent periodically. What other efficient ways of sending data serially (without interrupting the rest of the code) can I implement?

Thanks,
2  Using Arduino / Microcontrollers / Re: Replacing Arduino Due Chip (ATSAM3X8E) on: August 21, 2014, 11:23:48 am
So during my first attempt, I use some flush wire cutters - I should have been a little bit smarter of how I did that.

I do not have a proper hot air gun station. I have a hot air gun that can produce enough heat but the nozzle is around 1'' - 1.5'' in diameter (more like a high-powered hairdryer).  Controller the heat would be difficult and not melt the plastic female headers.  I still have a couple of burnt out Dues, so maybe I will just give it a shot.  

Daniel
3  Using Arduino / Networking, Protocols, and Devices / XBee: Not Working Properly on: August 21, 2014, 11:16:46 am
Hello,

I have two S1 XBee (linked below).  I have had them for a while now and decided to implement them into my design.

https://www.sparkfun.com/products/11215

One of them is working perfectly fine, while the other is giving me some issues.

1) Using XCTUNG (Mac version) I am unable to detect the XBee that isn't working properly

2) The operating voltage is interesting. Using the following shield from robotshop.com, I am doing to rudimentary testing by transmitting serial commands. I am noticing that the operating voltage, which I am scoping from the transmitting pin, is 700mV rather than 3V normal operation.

http://www.robotshop.com/ca/en/motomama-h-bridge-motor-driver-shield.html

What can I do to get the XBee to working properly?

Thanks,
4  Using Arduino / Microcontrollers / Re: Replacing Arduino Due Chip (ATSAM3X8E) on: August 20, 2014, 01:51:52 pm
First attempt went horribly wrong.  After cutting the pins, the pads are extremely sensitive and did peel right off.
5  Using Arduino / Microcontrollers / Re: Replacing Arduino Due Chip (ATSAM3X8E) on: August 20, 2014, 01:13:24 pm
Since the chip is burnt out, I can just cut off the leads and touch up the pads. And do some thermal air soldering for the new chip.

What do you think?
6  Using Arduino / Microcontrollers / Replacing Arduino Due Chip (ATSAM3X8E) on: August 20, 2014, 11:33:09 am
Hello,

Over the months I keep burning my Arduino Due - since I am prototyping and making my own PCBs and getting them to integrate nicely.

Now these boards have been piling up and I was wondering if I can easily replace the chip. I understand that the AVR Arduinos require a boot loader. I was wondering if the ARM chip needs one as well.

Thanks,

Daniel
7  Using Arduino / Programming Questions / Re: Using Quadrature Encoder Library - Issue on: August 14, 2014, 02:02:14 pm
So I am still not sure why this library wasn't working properly.

I resorted back my original method. It is 4x less resolved (since I am only using 1 interrupt on one channel) but it will do for now.

If someone can figure out why it isn't working. I will be happy to learn the explanation.
8  Using Arduino / Programming Questions / Re: Using Quadrature Encoder Library - Issue on: August 14, 2014, 11:18:14 am
Hello UKHeliBob

In software, I disabled some encoders and attempted to run each separately, but that was not the issue.

Using another (new) Arduino Due, doesn't solve the problem.

However, switching the connections (rather, switching the axes of the encoders to the Arduino) works. Telling me that the installation of the encoders and the developed controller itself is working no problem.

This comes down to the software and possibly the library.

Regarding switching the pins. I prefer to keep how it set up, since I have developed the PCB already. You may ask why I haven't tested it, well I have using my own code - but I would like to try and get this working with this library.

Also, thank you for noting the millis() concern. It was not problem, as I am debuging my code differently now - so that cannot be the issue.

If you are interested I am essentially now using the example linked previously.

Thank you again.

Code:
/*
Pin Definition

- Axial
  - MCHA --> 21
  - MCHB --> 20

- Radial
  - MCHA --> 19
  - MCHB --> 18
 
- Knob
  - MCHA --> 17
  - MCHB --> 16
*/

#define ENCODER_OPTIMIZE_INTERRUPTS

#include <Encoder.h>

#include <stdio.h>

// Master and Slave Encoder Signals

long mAxialPosition = 0;
long mRadialPosition = 0;
long mKnobPosition = 0;

Encoder mAxial(21, 20);
Encoder mRadial(19, 18);
Encoder mKnob(17, 16);

void setup()
{
  Serial.begin(9600); // PC
}

void loop() {
  long newAxial, newRadial, newKnob;
 
// Read Controller Encoders
  newAxial = mAxial.read();
  newRadial = mRadial.read();
  newKnob = mKnob.read();
 
  if (newAxial != mAxialPosition || newRadial != mRadialPosition || newKnob != mKnobPosition) {
  Serial.print("Axial = ");
  Serial.print(newAxial);
  Serial.print(", Radial = ");
  Serial.print(newRadial);
  Serial.print(", Knob = ");
  Serial.println(newKnob);
  mAxialPosition = newAxial;
  mRadialPosition = newRadial;
  mKnobPosition = newKnob;
  }

  if (Serial.available()) {
    Serial.read();
    Serial.println("Reset all counts to zero");
    mAxial.write(0);
    mRadial.write(0);
    mKnob.write(0);
  }


}
9  Using Arduino / Programming Questions / Using Quadrature Encoder Library - Issue on: August 14, 2014, 10:29:17 am
Hello,

I am using the following encoder library:

https://www.pjrc.com/teensy/td_libs_Encoder.html

I am using a 3-axis controller I developed, whereby I would like to use the library in order to find out the current positions of the axes.

The encoders were installed correctly, the signals are seen at the Arduino pins (by the way, I am using an Arduino Due) using an oscilloscope, but for some reason the output is only working correctly for 1 of the 3 axes. Not sure why I am not seeing all three working correctly. Thank you in advanced.

Code:
/*
Pin Definition

- Axial
  - MCHA --> 21
  - MCHB --> 20

- Radial
  - MCHA --> 19
  - MCHB --> 18
  
- Knob
  - MCHA --> 17
  - MCHB --> 16
*/

#define ENCODER_OPTIMIZE_INTERRUPTS

#include <Encoder.h>

#include <stdio.h>

// Master and Slave Encoder Signals

long mAxialPosition = 0;
long mRadialPosition = 0;
long mKnobPosition = 0;

Encoder mAxial(21, 20);
Encoder mRadial(19, 18);
Encoder mKnob(17, 16);

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if ((millis() % 100) == 0){
    Serial.print(mAxialPosition);
    Serial.print("||");
    Serial.print(mKnobPosition);
    Serial.print("||");
    Serial.println(mRadialPosition);
  }

// Read Controller Encoders
  mAxialPosition = mAxial.read();
  mRadialPosition = mRadial.read();
  mKnobPosition = mKnob.read();
}

Output Example

Code:
-1929||0||0
-1928||0||0
-1922||0||0
-1904||0||0
-1897||0||0
-1895||0||0
-1636||0||0
-818||0||0
422||0||0
1601||0||0
1768||0||0
984||0||0
-571||0||0
-2130||0||0
-2688||0||0
10  Using Arduino / Programming Questions / Re: Sending Strings using Arduino Console on: August 06, 2014, 04:24:59 pm
Oh my goodness..

For some reason the default mode on the Serial Monitor does not send a LF... All my original methods are working now.

Thank you for your guidance.
11  Using Arduino / Programming Questions / Re: Sending Strings using Arduino Console on: August 06, 2014, 03:28:14 pm
I tried making a boolean variable to make sure that it doesn't get printed before the concatenation is complete

Code:
 while (Serial.available()) {
    char myChar = Serial.read();
    Command.concat(myChar);
    commandReady = HIGH;
  }
  
  if (commandReady == HIGH) {
    Serial.println(Command);
    commandReady = LOW;
  }

I am still seeing the same output. How can I ensure that Serial is completely read before sending out the data?
12  Using Arduino / Programming Questions / Re: Sending Strings using Arduino Console on: August 06, 2014, 03:14:16 pm
AWOL,

Isn't that what I am doing by using a nested while() loop.

Also, just to edit, the output is actually being displayed after every 2 characters being concatenated.

Daniel
13  Using Arduino / Programming Questions / Re: Sending Strings using Arduino Console on: August 06, 2014, 03:09:39 pm
Hello BulldogLowell

My attempt at concat() ends up something like this:

Code:
  if (Serial.available()) {
    while (Serial.available()) {
      char myChar = Serial.read();
      Command.concat(myChar);
    }
    Serial.println(Command);
  }
 

But for some reason it is sending each concatenation rather than waiting for the full command to build up.

Anything you suggest I can do?

Daniel
14  Using Arduino / Programming Questions / Sending Strings using Arduino Console on: August 06, 2014, 01:01:19 pm
Hello,

I am having difficulty using my Arduino Due to communicate with another device via RS232. The devices response back to the arduino using chars but only accepts strings as inputs for commands.

I want to be able to use the console to tell a command to the Arduino, where the Arduino will then forward it to another Serial line to the device.

The response seems to be working correctly because during setup(), I am sending string commands to enable and configure the RS232 device. But to interact with it in real-time via console is giving me issues.

How do I correctly read the console serial data as a string and then Serial.print the command.

So far my code looks like this:

Code:
int ForceSensorPin = A8;
int LimitSwitchPin = 4;

volatile int LimitSwitchState = LOW;

void setup() {
  pinMode(LimitSwitchPin, INPUT);
  
  Serial.begin(9600);  // Computer
  Serial3.begin(9600); // RS232
 
  delay(1000);
  Serial3.println("EN");
  delay(100);
  Serial3.println("AC30000");
  delay(100);
  Serial3.println("DEC30000");
  delay(100);
  Serial3.println("SP10000");
}

char Command = 0;
char Response = 0;

void loop() {
  if (Serial.available()){
    Command = Serial.read();
    Serial3.print(Command);
  }
  if (Serial3.available()){
    Response = Serial3.read();
    Serial.print(Response);
  }
}
15  Using Arduino / Networking, Protocols, and Devices / Arduino UNO to DUE Communication via Serial on: July 21, 2014, 04:00:55 pm
Hello,

I am wondering if it is possible to using a USB-B to Micro USB cable to communicate between the UNO and DUE via the programming ports. I don't see how it is an issue (other than debugging of course). I haven't tried it yet, but I do want the community's opinion.

Thanks,
Daniel
Pages: [1] 2 3 ... 6