Show Posts
Pages: [1] 2
1  Using Arduino / Project Guidance / Steering Wheel Controls on: March 13, 2014, 08:31:46 pm
Hello,
I bought a Parrot Asteroid SMART stereo unit for my car. There are a few tutorials out there about using an Arduino UNO to read the signals basically on a 2 wire resistor ladder. It all seemed so so simple at the time but I am seriously running into trouble adapting it to my vehicle. I cant figure out how to approach it.

Here is the wiring diagram for the steering wheel controls:


Is this more of a Wheatstone bridge rather than a resistor ladder? Its so damn cold out I haven't tested this yet. But I have bread boarded a few test circuits to little success.

Could anyone offer any advice as to how to wire this to measure which button is pressed? I am assuming that +VCC is the center wire and the left and right wires are hooked up to an Analog pin to be read. Am I wrong?

Thanks in advance!
2  Using Arduino / General Electronics / Re: Step down 24V for PCB Laminator Modification on: April 16, 2013, 09:14:45 pm
You're sure that 24 volts is DC?  ...A transformer without a rectifier puts-out AC.
Yes, I measured it and its got a rectifier. Its a whole separate board within the unit to be clear.

Quote
Or, you can use a 7805 and bypass the Arduino's on-board regulator altogether.   The 7805 shouldn't overheat just driving the Arduino plus a relay that the Arduion can drive directly (less than 40mA).
Thats a great idea and the path I think I will try here first. I would be driving from another 7805 already in the unit, DUH! As I said I dont have room to properly mount a heat sync and dont want to go the 7812 route. Thanks!

Quote
If you have room for a few more components (including an inductor), a switching regulator would be nearly 100% efficient.
My engineering degree only included a basic EE lab course, and I am highly interested in modding and always to learn. if you wouldnt mind explaining this a bit I would be very appreciative. Thanks!
3  Using Arduino / General Electronics / Step down 24V for PCB Laminator Modification on: April 16, 2013, 07:17:16 pm
I am modifying a laminator I bought to do toner transfer. its pretty simple, I am basically using a relay to kill +V power to the motor driving the rolls to dwell under heat for 8 seconds, and allowing it to feed the board forward for 0.4 seconds and hold for another 8. Rinse and repeat. I have tested this in a proof on concept mode with a Mega2560 (powered separately) and it works GREAT! I am so pumped. Now the problem is powering an Arduino Nano inside the laminator case to run the the laminator in "PCB mode". The unit takes direct 120V AC and has a transformer board that outputs 24V DC for the heaters. From there a voltage regulator runs all the logic at 5V. Now the Arduino nano says no more than 6V (recommends 7-12) so I dont want to run it on 5V alone and have enough to power the relay.

Question is... I want to Step down from 24V and not over burden the 5V regulator by a 7812 to get 12V to the Nano. Note: I have no good way to heat sync with the remaining room I have left so I do not want to use a 7812 on the 24V line. Which is the better approach. And any suggestions on a transformer/regulator to step down from 24V in a small space and not worry about much heat?

Thanks in Advance!
4  Using Arduino / Displays / Re: UTouch.h button detection [SOLVED] on: March 03, 2013, 04:02:27 pm
I was able to figure this one out on my own. The proper syntax for button detection is this.

  //Button Detection
  if (myTouch.dataAvailable())
    {
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
      if (((y>=99) && (y<=119)) && ((x>=250) && (x<=293)))
      {
        if(button1State == false) {
          button1State = true;
          delay(50);  //delay for screen debounce
        } else {
          button1State = false;
          delay(50);  //delay for screen debounce
        }
      }
  }
5  Using Arduino / Displays / UTouch.h button detection [SOLVED] on: March 03, 2013, 08:07:11 am
I am working on a project with touch LCD screen using the UTouch.h library.

Basically I am trying to detect a button, but I cant use a while statement because I need my program to run in the background without refreshing the screen.

So I am trying to do something like:

  if(myTouch.dataAvailable() == true) {
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();
  
    if(x >= 250 && x <= 293 && y >= 99 && y <= 119)
    {
      if(button1State == false) button1State = true;
      if(button1State == true) button1State = false;
    }
  }

Its not working though. Any tips?
6  Products / Arduino Due / Re: Help Reading MAX31855 Thermocouple on Arduino Due on: February 28, 2013, 09:20:30 pm
jtw,
Thanks for the reply. In the meantime I have since solved this problem. If you want to Log a MAX31855 onto an SD Shield using an Arduino (which was my end goal) you cannot use the same clock, and MISO signals for both. That ended up being the cause of all the fuss. You must use an un-used digital pin for a mock clock and a mock MISO pin. The Adafruit MAX31855 library has you establish this in your sketch, its pretty self explanitory.

In my case I needed to read and log 4 seperate thermocouples. I ended up buying a Mega2560 for the extra pins and it works just great. Each slave (SD and thermocouple alike) has a chip select pin and the SD card shield uses the standard MOSI, MISO and SCK signals from the Arduino SPI interface. The only additional pins needed is like I said above a mock clock and a mock MISO pin that you set in your sketch for the Adafruit library.

I dont know if its possible to interface into the secondary SPI interface on the due yet. I have ordered a Mega prototyping shield and a kit of header pins to make a simple connector for both. I will update again when I get around to this.
7  Products / Arduino Due / Re: Help Reading MAX31855 Thermocouple on Arduino Due on: February 24, 2013, 05:15:12 pm
This device has no MOSI function, so it dosent matter what you send it. Basically, you drive (and keep) the chip select pin low for 32 clock cycles to read the data.

Thats basically what I am trying to do with the 4 bytes I have SPI_CONTINUE on the 1st 3. Your on the same page with me, just dosent seem to work though
8  Using Arduino / Networking, Protocols, and Devices / Re: [SOLVED] Need SPI Help! Multiple Slaves interfering (Not hardware related) on: February 24, 2013, 05:06:03 pm
Big thanks to pylon! I was able to solve this by using alternate pins and letting the software SPI functions read from pins seperate from the hardware SPI bus. I have got all 4 channels working and incorporated into an an example SdFat data logger. its working great!

Code:
/***************************************************
 * This is an example data logger for 4 thermocouple channels
 Based on Arduino Mega2560, Seeed Studio SD Shield, (4) MAX31855 Breakout Boards, and one DS1307 Real Time Clock from Adafruit
 
 Based on SdFat Data Logger Example, and Adafruit tutorials
  ****************************************************/

#include <Adafruit_MAX31855.h>
#include <Wire.h>
#include <RTClib.h>
#include <SdFat.h>
#include <SdFatUtil.h>

// A simple data logger for the Arduino analog pins
#define ECHO_TO_SERIAL   1 // echo data to serial port
#define WAIT_TO_START    0 // Wait for serial input in setup()
#define DATA_HEADER "Date, Time, TC#1(C), TC#1(F), TC#2(C), TC#2(F), TC#3(C), TC#3(F), TC#4(C), TC#4(F)"

// Serial print stream
ArduinoOutStream cout(Serial);

RTC_DS1307 RTC; // define the Real Time Clock object
SdFat sd;  // filesystem object
ofstream logfile; // the logging file

// format date/time
ostream& operator << (ostream& os, DateTime& dt) {
  os << dt.year() << '/' << int(dt.month()) << '/' << int(dt.day()) << ", ";
  os << int(dt.hour()) << ':' << setfill('0') << setw(2) << int(dt.minute());
  os << ':' << setw(2) << int(dt.second()) << setfill(' ');
  return os;
}
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
    DateTime now = RTC.now();
 
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());
 
  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());
}

const int SlavePin1 = 49; //Thermocouple #1
const int SlavePin2 = 47; //Thermocouple #2
const int SlavePin3 = 45; //Thermocouple #3
const int SlavePin4 = 43; //Thermocouple #4
const int SlavePin5 = 10; //SD Card
const int MockSlaveOut = 41;
const int MockClock = 39;

Adafruit_MAX31855 thermocouple1(MockClock, SlavePin1, MockSlaveOut);
Adafruit_MAX31855 thermocouple2(MockClock, SlavePin2, MockSlaveOut);
Adafruit_MAX31855 thermocouple3(MockClock, SlavePin3, MockSlaveOut);
Adafruit_MAX31855 thermocouple4(MockClock, SlavePin4, MockSlaveOut);

//*****************************************************************************************
// Error handling loop, from the tutorials at ladyada.net listed above
// If there is a problem accessing the SD card, this loop gets called to display a cryptic
// error message.
void error(char *str)
{
  Serial.print("error: ");
  Serial.print(str);
  while(1);
}
//****************************************************************************************

void setup() {
  digitalWrite(53, HIGH); //Power to    Thermocouple Boards
  Serial.begin(9600);
  cout << endl;
 
#if WAIT_TO_START
  // use pstr to store string in flash and save RAM
  cout << pstr("Type any character to start") << endl;
  while (!Serial.available());
#endif WAIT_TO_START

  // connect to RTC
  Wire.begin(); 
  if (!RTC.begin()) error("RTC failed");

  // set date time callback function
  //SdFile::dateTimeCallback(dateTime);
 
  // send date/time to Serial
  DateTime now = RTC.now();
  cout << now << endl;

  // see if the card is present and can be initialized:
  if (!sd.begin(SlavePin5, SPI_HALF_SPEED)) {
    // print detailed error message and halt
    sd.initErrorHalt();
  }
  // create a new file
  char filename[] = "LOG00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[3] = i/10 + '0';
    filename[4] = i%10 + '0';
    if (sd.exists(filename)) continue;
    logfile.open(filename);
    break;
  }
  if (!logfile) error("file create failed");
 
  cout << "Logging to: " << filename << endl;

  logfile << pstr(DATA_HEADER) << endl;
#if ECHO_TO_SERIAL
  cout << pstr(DATA_HEADER) << endl;
#endif ECHO_TO_SERIAL


}

void loop() {
  // use buffer stream to format line
  char buf[100];
  obufstream bout(buf, sizeof(buf));
 
  // fetch the time
  DateTime now = RTC.now();
 
  // log time
  bout << now <<", ";;
 
  //fetch Thermocouple Data 
  float c1 = thermocouple1.readCelsius();
  float f1 = thermocouple1.readFarenheit();
  float c2 = thermocouple2.readCelsius();
  float f2 = thermocouple2.readFarenheit();
  float c3 = thermocouple3.readCelsius();
  float f3 = thermocouple3.readFarenheit();
  float c4 = thermocouple4.readCelsius();
  float f4 = thermocouple4.readFarenheit();
  bout << c1 << ", " << f1 << ", " << c2 << ", " << f2 << ", " << c3 << ", " << f3 << ", " << c4 << ", " << f4;
 
  // write data to file
  logfile << buf << endl;
 
  logfile.flush();
 
  // check for errors
  if (!logfile) error("write data failed");
 
#if ECHO_TO_SERIAL
  cout << buf << endl;
#endif ECHO_TO_SERIAL
   
  delay(1500);
}
9  Products / Arduino Due / Help Reading MAX31855 Thermocouple on Arduino Due on: February 24, 2013, 09:29:21 am
Hello all, I am stuck on a problem trying to read the MAX31855 Thermocouple Amplifier from Adafruit.

Product Page:http://www.adafruit.com/products/269
Data Sheet: http://www.adafruit.com/datasheets/MAX31855.pdf
(The SPI details are found on page 9 and 10)

The problem is if you look at the Adafruit library, it dosen't use the SPI.h library and rather simulates the SPI transfer using a for loop and a digitalRead() on the slave out pin. The reason for this seems to be the MAX31855 itself. This device has no MOSI function, so it dosent matter what you send it. Basically, you drive (and keep) the chip select pin low for 32 clock cycles to read the data. The 32 bit value returned as an unsigned long should be compatible with the current library. The other things to consider is the chip has a 5MHz max limit, the data is presented on the falling edge from MSB to LSB. I believe I have it setup correctly.

My end goal is to read thermocouple data and log it onto an SD card. So I need to use the hardware SPI to interface with it. I have tested it separately and it works well. I am an engineer by day, and hobbiest by night. So I am not an expert, I appreciate both your patience and your help.

Here is an example of my code. I think it is clear what I am trying to do, but isnt working. Just trying to read the raw binary data out in serial. If i grab the thermocouple and warm it up I should see digits 2 through 14 shifting proving its working.

Code:
#include <SPI.h>

int SlavePin1 = 4; //Thermocouple #1

void setup() {
  Serial.begin(9600);
  Serial.println("Starting Program");
  //SPI Setup
  SPI.begin(SlavePin1);                // Setup SPI to use pin 4 as CS.
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SlavePin1,1);        // Use SPI Mode 1 (CPOL = 0, CPHA = 1)
  SPI.setClockDivider(SlavePin1, 21);  // Set SPI Clock divider to 21.(4MHz)
  Serial.println("SPI Variables Established");
  digitalWrite(SlavePin1, HIGH);   // Deselect MAX31855 chip
  Serial.println("Deselect MAX318555 Chip");
}

void loop() {
  Serial.println("Loop Started");
  union {
    byte byte1;
    byte byte2;
    byte byte3;
    byte byte4; 
    unsigned long longResult;
  } temperature;
 
  digitalWrite(SlavePin1, LOW);
  Serial.println("MAX31855 Selected");

  // read all 4 bytes
  temperature.byte1 = SPI.transfer (SlavePin1, 0xFF, SPI_CONTINUE);
  delay(1);
  Serial.println("Got byte 1");
  temperature.byte2 = SPI.transfer (SlavePin1, 0xFF, SPI_CONTINUE);
  delay(1);
  Serial.println("Got byte 2");
  temperature.byte3 = SPI.transfer (SlavePin1, 0xFF, SPI_CONTINUE);
  delay(1);
  Serial.println("Got byte 3");
  temperature.byte4 = SPI.transfer (SlavePin1, 0xFF);
  delay(1);
  Serial.println("Got byte 4");
  Serial.println (temperature, BIN);
  delay(1000);
}   
10  Using Arduino / Networking, Protocols, and Devices / Re: Fetching 32 bits of Data over SPI on Arduino Due on: February 24, 2013, 09:02:24 am
I think I will make a shorter post over there summarazing what I have learned thus far...

One interesting thing is I modified the code slightly to be used on a MEGA 2560 that I also have and the for loop is working but it just returns a 0 on the output everytime.

In any event I would ask one last question on this. How would the code be modified to read bit by bit from the thermocouple? (I dont even know if this is standard with the SPI library) For example, the 1st bit is the sign of the temperature reading, the next 13 are the temperature over the thermocouple. There is a reserved and fault bit in between, and then the next 12 bits are the chips internal data. The remaining 4 bits are fault detectors.

So really what I am trying to do on a transfer level is read the 1st bit as 0 or 1, negative or positive respectively. Read bits 2-14 into a variable for the thermocouple temperature. Then read bits 17-29 for the chip temperature. There are various examples out in the public domain of how to convert the binary data into digestible temperature data formats. But I cant read the data. Sorry if this is a naive question, but I am trying to learn as much as I can here
11  Using Arduino / Networking, Protocols, and Devices / Re: Fetching 32 bits of Data over SPI on Arduino Due on: February 23, 2013, 05:28:32 pm
Nick,
Thank you for the continued help, and the code snippet. I tried this (with some adding debugging serial printouts) and the for loop dosent seem to be looping.

Here is the serial output:
Starting Program
SPI Variables Established
Deselect MAX318555 Chip
Loop Started
MAX31855 Selected
For Loop #
0

And the exact code I am using
Code:
#include <SPI.h>

int SlavePin1 = 4; //Thermocouple #1

void setup() {
  Serial.begin(9600);
  Serial.println("Starting Program");
  //SPI Setup
  SPI.begin(SlavePin1);                // Setup SPI to use pin 4 as CS.
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SlavePin1,1);        // Use SPI Mode 1 (CPOL = 0, CPHA = 1)
  SPI.setClockDivider(SlavePin1, 21);  // Set SPI Clock divider to 21.(4MHz)
  Serial.println("SPI Variables Established");
  digitalWrite(SlavePin1, HIGH);   // Deselect MAX31855 chip
  Serial.println("Deselect MAX318555 Chip");
}

void loop() {
  Serial.println("Loop Started");
  union {
    byte byteResult [4];  
    unsigned long longResult;
  } temperature;
  
  digitalWrite(SlavePin1, LOW);
  Serial.println("MAX31855 Selected");

  // read all 4 bytes
  for (byte i = 0; i < 4; i++) {
    Serial.println("For Loop #");
    Serial.println(i);
    temperature.byteResult [i] = SPI.transfer (0);
    Serial.println("Data Transfered ");
    delay(1);
  }

  digitalWrite(SlavePin1, HIGH);
  Serial.println("Deselect MAX318555 Chip");
    Serial.println (temperature.longResult);
  delay(1000);
}  

Also here is the Serial instructions from the data sheet (page 9)
http://www.adafruit.com/datasheets/MAX31855.pdf
I believe I have the serial interface established correctly in the listed parameters above. But I am not an expert.

Drive CS low and apply a clock signal at SCK to read the results at SO. Conversions are always being performed in the background. The fault and temperature data are only be updated when CS is high. Drive CS low to output the first bit on the SO pin. A complete serial-interface read of the cold-junction compensated thermocouple temperature requires 14 clock cycles. Thirty-two clock cycles are required to read both the thermocouple and reference junction temperatures (Table 2 and Table 3.) The first bit, D31, is the thermocouple temperature sign bit, and is presented to the SO pin within tDV of the falling edge of CS. Bits D[30:18] contain the converted temperature in the order of MSB to LSB, and are presented to the SO pin within tD0 of the falling edge of SCK. Bit D16 is normally low and goes high when the thermocouple input is open or shorted to GND or VCC. The reference junction temperature data begins with D15. CS can be taken high at any point while clocking out conversion data. If T+ and T- are unconnected, the thermocouple temperature sign bit (D31) is 0, and the remainder of the thermocouple temperature value (D[30:18]) is 1.
12  Using Arduino / Networking, Protocols, and Devices / Re: Fetching 32 bits of Data over SPI on Arduino Due on: February 23, 2013, 10:10:18 am
Bingo.... there is no MOSI for this part above I stated
Normally correct but there is no MOSI for this device it reads out only. Quoting directly from the datasheet "Drive CS low and apply a clock signal at SCK to read the results at SO" The limit of the chip is 5 MHz so I set it at 4 as you can see by the code above.
13  Using Arduino / Networking, Protocols, and Devices / Re: Fetching 32 bits of Data over SPI on Arduino Due on: February 23, 2013, 10:04:30 am
Paul,
I edited a key note above.

My desire to print in Binary results in the data sheet. The 32 bits contains temperature data, fault data, etc all in a nice table. If I can see what 1 and 0's are on/off I can debug alot more information.

I tried it... changing my loop to the following didnt change the serial readout.

Code:
void loop() {
  digitalWrite(SlavePin1, LOW);
  unsigned long someValue = 0xFFFFFFFEUL;
  transfer(someValue);
  readback = transfer(0);
  data = transfer(someValue);
  Serial.println(data, BIN);
  digitalWrite(SlavePin1, HIGH);
  delay(1000);
}
14  Using Arduino / Networking, Protocols, and Devices / Re: Fetching 32 bits of Data over SPI on Arduino Due on: February 23, 2013, 09:49:13 am
Okay I am trying from the suggestions provided but am getting limited results.

Here is the code I am trying, but it is returning is 25 bits. I am sure I am making an idiot mistake here

The serial output is
"1000000010000000100000001"


Code:
/***************************************************
 * Custom MAX31855 Library using hardware based SPI.h
/****************************************************/

#include <SPI.h>

union FourByte{
    unsigned long bit32;
    unsigned int bit16[2];
    unsigned char bit8[4];
};

int SlavePin1 = 4; //Thermocouple #1
long unsigned data;

void setup() {
  Serial.begin(9600);
  pinMode(SlavePin1, OUTPUT);
  digitalWrite(SlavePin1, HIGH); //Disable SS
  SPI.begin(SlavePin1);                // Setup SPI to use pin 4 as CS.
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SlavePin1,1);        // Use SPI Mode 1 (CPOL = 0, CPHA = 1)
  SPI.setClockDivider(SlavePin1, 21);  // Set SPI Clock divider to 21.(4MHz)
  
}

unsigned long transfer(unsigned long value){
  FourByte data = {value};
  for(byte i = 0; i < 4; i++){
    data.bit8[i] = SPI.transfer(SlavePin1, data.bit8[i]);
    delay(1);
  }
  return data.bit32;
}

void loop() {
  digitalWrite(SlavePin1, LOW);
  unsigned long someValue = 0xFFFFFFFEUL; //No MOSI on MAX31855, dosent matter what is sent.
  data = transfer(someValue);
  Serial.println(data, BIN);
  digitalWrite(SlavePin1, HIGH);
  delay(1000);
}

Oh one last thing.... the Datasheet for the MAX31855 states the following:

Drive CS low to output the first bit on the SO pin. A
complete serial-interface read of the cold-junction compensated thermocouple temperature requires 14 clock
cycles. Thirty-two clock cycles are required to read both
the thermocouple and reference junction temperatures

With my for loop only cycling 3 times, is this my issue? If so how can my code be modified to the same end result of bringing out all 32 binary bits in the serial interface. If thats working I can get to my final goal from there.
15  Using Arduino / Networking, Protocols, and Devices / Re: Fetching 32 bits of Data over SPI on Arduino Due on: February 22, 2013, 10:39:52 pm
Normally correct but there is no MOSI for this device it reads out only. Quoting directly from the datasheet "Drive CS low and apply a clock signal at SCK to read the results at SO" The limit of the chip is 5 MHz so I set it at 4 as you can see by the code above. This is really the source of my confusion as to how to resolve this. There is no SPI.read() function like SPI.transfer()
Pages: [1] 2