Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: String value to ASCii via serial interface on: March 29, 2011, 05:09:48 pm
Fantastic, works a treat, many thanks.  smiley
2  Using Arduino / Programming Questions / String value to ASCii via serial interface on: March 27, 2011, 09:10:21 pm
Hi all,

I know this is going to be easy, but my searching hasn't found the answer. I need to convert a string such as
CSp2134Sp7128Sp0SpCR (where Sp = space and CR = carriage return) to ascii and send it out the serial monitor (and later a second serial port) which would in this case be 673250495152325549505632483213

Can someone please point me in the right direction.

Many thanks
Colin.
3  Using Arduino / General Electronics / Re: PIC16F628A to Arduino (rs-232 data) on: March 10, 2011, 09:59:12 pm
Thanks for the reply. There is nothing but a 1k resistor on the output of the pic, so it looks like TTL --> TTL will be a go. I see that new softserial can also take care of an inversion if it's present.

The project should work ok with the library, the basics are this;

Read 2 values from the hardware rs-232 port connected to a pc; //com 1
Based on one input value move a motor until the value from the sensor (a feedback sensor from the motor) = the input value; //com2
Based on the second input value move a second motor until the value from a second sensor (again a feedback sensor from the motor) = the input value; //com3

As this all happens in "serial" fashion I'm hoping that the library will cope.

Otherwise I'd be open for suggestions  smiley
4  Using Arduino / General Electronics / PIC16F628A to Arduino (rs-232 data) on: March 10, 2011, 09:27:23 pm
Hi all,
Hopefully this question is in the right forum.

I am building a project which needs to read "rs-232" data from a PIC16F628A based sensor board. I was intending to use the "newsoftserial' library as I have a total of 3 rs-232 interfaces, 1 from a PC and 2 from the pic based sensors. The pic sensors are not my development, but I do have email communication with the developer.

My question is, will I need to do any logic inversion/isolation or can I simply connect the output of the pic to the input of the Arduino (in the fashion of TTL --> TTL) and read the data? There is no requirement to transmit any data back to the sensor boards.

Many thanks
Colin.
5  Using Arduino / Programming Questions / Re: Running code out of the main loop? on: February 18, 2011, 11:57:11 pm
Great thanks, so is it good coding practice to write my code with functions outside the main loop like this, or is that a decision largely driven by the code itself (hope that makes sense too  smiley-slim). I guess I'm trying to ask if there are 2 ways of running my functions - inside the main loop and outside the main loop and which to use when?
6  Using Arduino / Programming Questions / Running code out of the main loop? on: February 18, 2011, 10:49:38 pm
Hi all,
Another newbie question I'm afraid.

Is this permissible with an Arduino sketch, if so under what circumstances is it used?

void loop
{
// main loop with some code in here

othercode() //At some stage I want out of the main loop to run othercode()
}

void othercode()

{
//run othercode in here
}

When othercode is finished running do I return to where I came from in the main loop?

I've seen something similar in a sketch and was just wanting to understand it's use.

Cheers
Colin

7  Using Arduino / Project Guidance / Re: Are stepper motors right for this project? on: February 14, 2011, 05:42:48 pm
Hi  Mike and Lefty,

Thanks for the feedback. I'm looking at a light weight Arrow type sat antenna for the ham sats. I intended to have it well balanced so as little torque as possible was required to move it (at least in elevation).

Tracking speed as you rightly point out will be pretty slow. I'm using WXtrack to output the Az/El commands and so far have Arduino displaying those numbers on an LCD. My next step was to get the math right for pointing. Update speed from the PC is anything from 1/sec to 1/min. I was thinking along the lines of every 5 secs, which is still a few degrees change on a high angle pass.

I was trying to avoid the complication of gearing the motors, but it looks like in reality I may have to. There are a bunch of DC geared motors around that are cheap and will have heaps of torque, so maybe I should head down that route. Back to the mechanical drawing board  smiley-cool

(73's ZL2ARL)
8  Using Arduino / Project Guidance / Are stepper motors right for this project? on: February 14, 2011, 04:42:04 pm
Hi all,

I have embarked on a project to build an antenna rotator (azimuth and elevation ). I chose stepper motors in the (possibly mistaken) belief that they could provide me with the pointing accuracy I was looking for, which is 1 degree.

The motors I have are a common 1.8deg per step 200 step per rev motor. In microstepping mode they are of course 1600 steps per rev which equates to 0.225 deg per step.

So here my problems start with trying to point at say 10 degrees, which is 44.44 [recurring] steps (10 \ 0.225)- which I'm assuming a stepper cannot handle. So 44 steps is probably close enough in the grand scheme of things, but then I am thinking that I will start running into rounding errors and the accuracy will get further and further off. At the end of each tracking session I will reset my steppers to a known "0" point using switches, so I have a known start point for each session.

So... have I

a) Gone the wrong way with using steppers
b) Got the math wrong
c) Approached the calculation for stepping wrong
d) Got too worried about the math and accuracy
e) None of the above/all of the above ??

Any and all thoughts appreciated.

Colin.
9  Using Arduino / Motors, Mechanics, and Power / Re: EasyDriver v4.3 and sparkfun Stepper motor woes on: February 06, 2011, 01:04:46 am
This may be a silly question - but is your wallwart outputting 12v DC or 12V AC? I know I've got a few at home that are AC output, it's caught me once or twice. smiley-cool

If it is DC can you check the volts with a multimeter when it's trying to run the motors to see if maybe it's dying under load?
10  Using Arduino / Programming Questions / Re: Parsing an ascii string from serial input on: February 03, 2011, 01:36:30 pm
Fantastic, thanks very much for the help. I thought I may be needing the strstr()function, so at least I was thinking in the right direction even if I couldn't quite work it out.  smiley-confuse
11  Using Arduino / Programming Questions / Re: Parsing an ascii string from serial input on: February 03, 2011, 01:50:23 am
Thanks for that - I think I understand most of it  smiley-slim

I'm having trouble getting my head around the variable length of my data. What I do know is that whatever is between the "AZ" and the "." needs to become one token and whatever is between "EL" and "." is another.
Anything else can be discarded.

Each of these will be used later to drive 2 stepper motors.
12  Using Arduino / Programming Questions / Re: Parsing an ascii string from serial input on: February 02, 2011, 05:26:08 pm
I just changed those "i" characters  smiley

Thanks very much for your help. At first I looked at your initial reply and went "what the....!" But after I read it a couple of times I was able to go away and actually find the answers - great stuff. I have to say at 50 years old my brain hurts just from this little bit  smiley-confuse My last foray into programming was with VB many (too many) years ago  smiley-roll-sweat
13  Using Arduino / Programming Questions / Re: Parsing an ascii string from serial input on: February 02, 2011, 05:07:19 pm
Ok, so if I understand you right I need to;

Declare a char array along the lines of;

char inputData[17]                  //Using a max 16 char of data and 1 for the null

Then read my serial data into the array along the lines of;

if(Serial.available() > 16) {
        for(int j = 0; j < 16; j++){
           iputData[j] = Serial.read();
        }

Then I can work on parsing it out?

14  Using Arduino / Programming Questions / Parsing an ascii string from serial input on: February 02, 2011, 03:38:26 pm
Hi all,
Could some of you fine people please steer me in the right direction.

I have started a project to build an antenna rotator for Amatuer radio use. It will be driven by a sattelite tracking program suppling simple ascii commands via a comm port. I am trying to take this a few steps at a time and so far have the data being displayed on an lcd screen  smiley

My next step is to try and parse the data so I can use each of 2 numbers to move servo motors to their correct position.

The ascii data is in the format of "AZxxx.x[space]ELyyy.yCRLF". (AZ = Azumith degress, EL = Elevation degrees)
The first issue is that the xxx.x and yyy.y are variable length (i.e it may be 1.0, 23.0, 123.0) but they are never negative. The constants in the string are the AZ, EL, the decimal point, the [space] and the crlf at the end. The number after the decimal point is always zero.

What I need to end up with is 2 pieces of data to be passed to the rest of the code, I guess in variables that could be named something like AzData and ElData. I don't need decimal accuracy so whole numbers would work great. The data is updated by the pc couple of seconds.

The very basic code so far is;
Code:
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}

Many thanks
Colin.
15  Using Arduino / Motors, Mechanics, and Power / Re: EasyDriver v4.3 and sparkfun Stepper motor woes on: February 02, 2011, 04:26:29 am
According to the Easy Driver web site

"Each EasyDriver can drive up to about 750mA per phase of a bi-polar stepper motor."
Pages: [1] 2