Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / Re: Problem connecting to TI ADS1212P via SPI on: May 22, 2012, 11:06:37 am
Yes, we ended up getting a 2MHz crystal to make it work.
2  Using Arduino / Networking, Protocols, and Devices / Re: Problem connecting to TI ADS1212P via SPI on: April 10, 2012, 07:41:47 pm
I do have SDOUT connected to MISO. The pin definitions list reads as if using SDIO for both input and output is optional, but I see in the Command Register bit descriptions that it does both input and output by default. I have modified my code to try to blindly send the command to change that, but it doesn't seem to be working for me. I'm still getting the same data back as I sent to the ADC.

Code:
#include <SPI.h>

#define PIN_SCK          13             // SPI clock
#define PIN_MISO         12             // SPI data input
#define PIN_MOSI         11             // SPI data output
const int dataReadyPin = 9;
const int chipSelectPin = 10;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV128);
  SPI.setDataMode(SPI_MODE1);
  pinMode(dataReadyPin, INPUT);
  pinMode(chipSelectPin, OUTPUT);
  digitalWrite(chipSelectPin,HIGH);
 
  while (digitalRead(dataReadyPin) == LOW) { //Wait until this goes high
    delay(1);
  }
  digitalWrite(chipSelectPin,LOW);
  Serial.println("Setting CMD:SDL");
  SPI.transfer(B00000100); //Write to Command Register Byte 3
  SPI.transfer(B01000010); //Set SDL to use SDOUT
  digitalWrite(chipSelectPin,HIGH);
  delay(250);
}

void loop() {
  if (digitalRead(dataReadyPin) == HIGH) {
    digitalWrite(chipSelectPin,LOW);
    byte b0 = SPI.transfer(B10000000);
    Serial.println(b0,BIN);
    digitalWrite(chipSelectPin,HIGH);
    delay(250);
  }
}
3  Using Arduino / Networking, Protocols, and Devices / Problem connecting to TI ADS1212P via SPI on: April 10, 2012, 01:28:30 pm
Hello everyone. I need an ADC with more resolution than the one built in to the ATMega. I have a Texas Instruments ADS1212P that I have connected to my Arduino and I'm trying to get the two to talk via SPI, but I'm running in to issues.

Here is my sketch:
Code:
#include <SPI.h>

#define PIN_SCK          13             // SPI clock
#define PIN_MISO         12             // SPI data input
#define PIN_MOSI         11             // SPI data output
const int dataReadyPin = 9;
const int chipSelectPin = 10;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV128);
  SPI.setDataMode(SPI_MODE1);
  pinMode(dataReadyPin, INPUT);
  pinMode(chipSelectPin, OUTPUT);
  digitalWrite(chipSelectPin,HIGH);
}

void loop() {
  if (digitalRead(dataReadyPin) == HIGH) {
    digitalWrite(chipSelectPin,LOW);
    byte b0 = SPI.transfer(B10000000);
    Serial.println(b0,BIN);
    digitalWrite(chipSelectPin,HIGH);
    delay(250);
  }
}

My serial output looks like this:
10000000
10000000
10000000
10000000

It appears that the byte I get back from the device is exactly the same as the byte I send to it. Any idea what I'm doing wrong?

The device manual is here:
http://www.ti.com/lit/ds/symlink/ads1213.pdf

Thanks,
Lance
4  Forum 2005-2010 (read only) / Bugs & Suggestions / Windows 7 x64 sometimes locks up on upload on: September 02, 2009, 09:18:50 am
Greetings. I have a 64 bit Windows 7 box, and Arduino 0017 software. Approximately 10% of the time, uploading code to the Arduino will cause the PC to lock up. Complete lock - mouse stops, no audio.

I have also done some uploads on a 32 bit Windows 7 box, and haven't once seen it lock up.

-Lance
5  Forum 2005-2010 (read only) / Bugs & Suggestions / Is there a small firmware upload-only program? on: September 22, 2009, 10:18:48 pm
Lets say I have an arduino in use somewhere far away that I wanted to change firmware on. I would like to change the script here and e-mail it to someone where the arduino is. Is there a lite version of the IDE that someone could use to upload new firmware to the device? Possibly pre-compiled on my end, and just e-mail the compiled firmware and an uploading app (for windows) to the person with the device? The idea being that the other person doesn't have to mess with downloading and decompressing the 80MB IDE.

-Lance
6  Forum 2005-2010 (read only) / Interfacing / Code Sample: Serial Port ASCII Commands on: October 03, 2009, 09:10:48 pm
I have an arduino connected to a computer via serial, and needed a way to set some variables on the arduino. I've noticed that it is really easy to get ASCII data out of the arduino, but I needed a way to read and parse incoming commands. Here is a code example for anyone else that wants to do something similar:

Code:
boolean blinky = false;
char buffer[24];
byte bufferindex = 0;
long number = 0;
boolean negative = false;
boolean baddata = false;

long SomeVariable = 0;

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  while (Serial.available()) {ReadSerialData(Serial.read());}

  blinky = !blinky;
  digitalWrite(13, blinky);
  delay(100);
}


void ReadSerialData(char inChar) {
  if (bufferindex == 25) bufferindex = 0;
  buffer[bufferindex] = inChar;bufferindex++;
  if (inChar == 10) {
    if (bufferindex > 2) {
      if (buffer[bufferindex - 2] == 13) {
        bufferindex -= 3; //Decrement by 3 to get back to the 10
        ParseSerialCommand();
      }
    }
  bufferindex = 0;
  }
}

void ParseSerialCommand() {
  number = 0;negative=false;baddata = false;
  if (bufferindex > 0) {
    if (buffer[1] == 45) {negative=true;} //first char is -, so set negative flag
    for(int i=1; i<=bufferindex;i++){
      if (buffer[i] >= '0' && buffer[i] <= '9') {
        number = number * 10 + (buffer[i] - 48);
      } else {if (buffer[i] != 45) {baddata = true;}} //ignore any minus signs
    }
    if (negative) {number = 0 - number;}
  }
  if (baddata) {buffer[0] = 13;}

  if (buffer[0] == 115) { //s = SomeVariable
    SomeVariable = number;
    Serial.print("SomeVariable was set to: ");Serial.println(SomeVariable); //Remove this line if you don't want confirmation
  }
  
  if (buffer[0] == 63) {Serial.println("Version=0.0.0.0;Serial ASCII Command Processor");}//?
  if (buffer[0] == 126) { //~ Diagnostics
    Serial.println("---DIAGS---");
    Serial.print("SomeVariable=");Serial.println(SomeVariable);
    Serial.print("Blinky=");Serial.println(blinky, DEC);
    Serial.println("------");
  }
}

If you type the letter "s" followed by a number and press enter, you will set SomeVariable to that number. An example would be "s255" to set SomeVariable to 255. Make sure your carriage return is followed by a line feed.

-Lance
7  Forum 2005-2010 (read only) / Interfacing / Re: Driving 12vDC Solenoids on: September 08, 2009, 08:52:11 am
Oh, OK. Now I see the note in your first post about it being a pulse current. Must have missed that before. Thanks.
8  Forum 2005-2010 (read only) / Interfacing / Re: Driving 12vDC Solenoids on: September 07, 2009, 09:12:04 pm
Thanks for the insight, guys. I connected the solenoid up to a test circuit today, controlled by a TIP120, with a 1N4004 parallel to the solenoid. After a minute of use, the TIP120 was warm to the touch (no heat sink), and the diode was still room temp. At 100% PWM duty cycle, I was seeing 1 volt of drop across the TIP120. At ~1.5 amps, it was creating 1.5 watts of heat.

I plan to replace the TIP120 with a FDP6030BL mosfet, which has a RDSon of 0.018 ohms. I think that should allow me to power the solenoid without a heat sink. At a typical 1.5 amps, the mosfet should produce 0.04 watts of heat. Even at a worse case 5 amp load, it would only have to dissipate 0.45 watts of heat.

I'm having trouble finding a diode with a 5+ amp rating. Any recommendations?
9  Forum 2005-2010 (read only) / Interfacing / Re: Driving 12vDC Solenoids on: September 06, 2009, 09:49:30 am
Because that is exactly what they are designed for. It is a proportional hydraulic valve, so the stronger the magnetic field, the more open the valve is, and the more oil it flows.
10  Forum 2005-2010 (read only) / Interfacing / Driving 12vDC Solenoids on: September 05, 2009, 09:25:54 pm
I've been searching and reading about various circuits to drive solenoids, but still have a couple questions.

The solenoids I want to drive are on a vehicle, so 12vDC (~14v with engine running). They are rated at 1.6 amps, but obviously the driving circuit should be oversized. Also, I want to drive them with a PWM signal. These solenoids control a hydraulic valve that will steer the vehicle, so only one will be on at a time.

Initially I wanted to use some solid state relays, but it appears they don't do switching fast enough for PWM to really work right.

I have since started looking into the transistor circuits, such as:
http://www.arduino.cc/playground/uploads/Learning/solenoid_driver.pdf

Using a common ground between the arduino circuit and the solenoids is fine for this application.

I see that the TIP120 (rated at 5A) should be sufficient for the load I have, but will need to have a decent heat sink attached to it.

What I'm curious about is the protection diode - how many amps does that need to be rated at?

-Lance
11  Forum 2005-2010 (read only) / Exhibition / Re: Steering a combine via GPS on: October 19, 2010, 09:09:56 pm
Originally I was using a Duemilanove that was wired to a prototyping PCB that had some TO-220 MOSFETs for switching higher amperage power that controlled solenoids on the steering valve. I have since developed a couple PCBs that have everything I need on one card - power regulation, the ATMega, TTL-to-RS232 translator, valve driver MOSFETs, and some sensor inputs.

A vehicle that moves at 10 MPH will have very accurate heading data at that speed, but a tiny amount of heading error will drive you away from your desired path quickly. Getting accurate heading data will still require a yaw sensor coupled to a magnetometer or GPS.
12  Forum 2005-2010 (read only) / Exhibition / Re: Steering a combine via GPS on: April 05, 2010, 09:21:40 am
Yield monitoring on a combine typically uses weight sensor to feel how much impact the incoming grain has as it comes in to the hopper. They put the sensor at the top of the clean grain elevator so as it comes up the elevator and gets thrown off at the top, the grain hits the sensor. There is also a moisture sensor to calculate shrink. Test weight has to be estimated, which is where you will get a lot of error when going from one hybrid to another.

The system will need to be calibrated for different flow rates. There are also patents on the algorithms. Ag Leader uses a curved calibration line, and John Deere is linear.

The newer systems use CanBus sensors, so if you feel like sniffing the bus, you can pull the raw data and try to calculate it yourself.
13  Forum 2005-2010 (read only) / Exhibition / Re: Steering a combine via GPS on: January 24, 2010, 11:51:53 pm
Thanks for the kind words.

I guess I am a circuit nerd, just not in the professional sense. I enjoy waking up whenever I feel like it (usually ~10AM). Did the IT thing for a while, but I eventually realized that I would never get rich working for someone.

My o-scope and basic electronic skills are from college. Programming is self taught. Currently trying to learn C++ on Eclipse (which is a sucky platform compared to microsoft visual anything).

Warranty on new equipment is typically 1 year, so my test mule was well out of warranty. The iron manufacturers are aware of what I'm doing, but their employees can't say much in public, such as on a forum.

I've never had an issue with connections vibrating loose.

-Lance
14  Forum 2005-2010 (read only) / Exhibition / Re: Steering a combine via GPS on: January 24, 2010, 07:24:19 pm
For steering, I calculate a desired steering angle from a few components (speed, offline distance, heading relative to target heading, and wheelbase length). I then use a PI loop to get the steer angle to the desired steer angle, using a potentiometer as feedback of the steering angle. The output of the PI loop controls two solenoids that move hydraulic oil to the steering cylinder. In my case, it took a PWM value to 90 to get the valve to open, and full open was 255. You'll find a similar situation with an electric motor where it will take a certain level of PWM to get the motor to turn at all.

I have mostly dropped the Arduino as a development platform for steering, in favor of a Netburner. I intend to do communication to the cab computer via Ethernet instead of USB, although I may retain an Arduino for Analog to Digital and valve control. The intent is for the Netburner to do 100% of the steering control, IMU calculations, and read from a GPS receiver, which all gets controlled via web browser.
15  Forum 2005-2010 (read only) / Exhibition / Re: Steering a combine via GPS on: December 31, 2009, 12:03:28 am
I've read a bit about the ArduPilot project, and it appears to be growing at a healthy pace. I'll look into it more deeply in February/March when I start prepping for spring planting. Working on some other projects currently.

I think it would be easier to couple GPS to IMU data on an airplane due to the high speed. The slower you go, the longer the time delay between when your heading changes and when you can pick that up in the GPS data. Even the big name companies are only able to make it work down to about 0.5 MPH. In addition, the location of the GPS antenna relative to the solid axle has an effect on how the GPS data can be used to correct the IMU data.

The valve controller is a pair of N-channel logic level mosfets that drive the two solenoids on my hydraulic valve. I think I even got the basic schematic off this forum, and adapted it for my load requirements.

Basically there is a Windows computer that gets NMEA data from a GPS receiver, determines how far offline it is from the target path, adds any tilt correction to that, and then determines what angle the steer axle should be at to get back to that desired line. Then a PI loop takes over and moves the steering valve left or right to get the steer axle angle to the desired position. The windows computer also keeps track of where the machine has been (coverage map) and shows that to the user as a 3d map in DirectX. The coverage map can also be used to turn things on and off to eliminate overlap of chemicals, seed, fertilizer, etc.

-Lance
Pages: [1] 2