Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Programming Questions / Re: Parsing data packets on: November 02, 2013, 03:41:38 pm
I mean char to its dec number equivalent.   Such as        - is equal to 45   
                                                                                                 ! is equal to 33
17  Using Arduino / Programming Questions / Re: Parsing data packets on: November 02, 2013, 03:14:23 pm
This is example code I got off of there site.  It works with the elecGuru software, so I know it is possible.  The software they offer is not open source, and not finished.  I would like to read the data in to LabView.  I just need to understand how to parse it.

Looks like I need to change the char to dec.
18  Using Arduino / Programming Questions / Re: Parsing data packets on: November 02, 2013, 02:58:47 pm
I'm trying to figure out what is being sent to the serial port.  this piece of code is filling the buffer with the packet header, data, and footer I assume...

Code:
for(CurrentCh=0;CurrentCh<6;CurrentCh++){
    ADC_Value = analogRead(CurrentCh);
    TXBuf[((2*CurrentCh) + HEADERLEN)] = ((unsigned char)((ADC_Value & 0xFF00) >> 8)); // Write High Byte
    TXBuf[((2*CurrentCh) + HEADERLEN + 1)] = ((unsigned char)(ADC_Value & 0x00FF)); // Write Low Byte
  }

So is the ADC_Value a char?

I attached a pic of the serial output.

19  Using Arduino / Programming Questions / Parsing data packets on: November 02, 2013, 02:43:16 pm
Hello everyone,

I am trying to build some software with labview to read the data packets coming from the Arduino.  I have a mega hooked up to an Olimex ECG Shield.  https://www.olimex.com/Products/Duino/Shields/SHIELD-EKG-EMG/.  I am having trouble understanding the example code. 

The serial monitor spits out a bunch of characters.  I think I see the start bit, 7 data bits, and a stop bit but its all in char.  How do I make since of this data?  Any help would be appreciated.  Thanks!

Code:
/**********************************************************/
/* Demo program for:                                      */
/*    Board: SHIELD-EKG/EMG + Olimexino328                */
/*  Manufacture: OLIMEX                                   */
/*  COPYRIGHT (C) 2012                                    */
/*  Designed by:  Penko Todorov Bozhkov                   */
/*   Module Name:   Sketch                                */
/*   File   Name:   ShieldEkgEmgDemo.ino                  */
/*   Revision:  Rev.A                                     */
/*    -> Added is suppport for all Arduino boards.        */
/*       This code could be recompiled for all of them!   */
/*   Date: 19.12.2012                                     */
/*   Built with Arduino C/C++ Compiler, version: 1.0.3    */
/**********************************************************/
/**********************************************************
Purpose of this programme is to give you an easy way to
connect Olimexino328 to ElectricGuru(TM), see:
https://www.olimex.com/Products/EEG/OpenEEG/EEG-SMT/resources/ElecGuru40.zip
where you'll be able to observe yours own EKG or EMG signal.
It is based on:
***********************************************************
* ModularEEG firmware for one-way transmission, v0.5.4-p2
* Copyright (c) 2002-2003, Joerg Hansmann, Jim Peters, Andreas Robinson
* License: GNU General Public License (GPL) v2
***********************************************************
For proper communication packet format given below have to be supported:
///////////////////////////////////////////////
////////// Packet Format Version 2 ////////////
///////////////////////////////////////////////
// 17-byte packets are transmitted from Olimexino328 at 256Hz,
// using 1 start bit, 8 data bits, 1 stop bit, no parity, 57600 bits per second.

// Minimial transmission speed is 256Hz * sizeof(Olimexino328_packet) * 10 = 43520 bps.

struct Olimexino328_packet
{
  uint8_t sync0; // = 0xa5
  uint8_t sync1; // = 0x5a
  uint8_t version; // = 2 (packet version)
  uint8_t count; // packet counter. Increases by 1 each packet.
  uint16_t data[6]; // 10-bit sample (= 0 - 1023) in big endian (Motorola) format.
  uint8_t switches; // State of PD5 to PD2, in bits 3 to 0.
};
*/
/**********************************************************/
#include <compat/deprecated.h>
#include <FlexiTimer2.h>
//http://www.arduino.cc/playground/Main/FlexiTimer2

// All definitions
#define NUMCHANNELS 6
#define HEADERLEN 4
#define PACKETLEN (NUMCHANNELS * 2 + HEADERLEN + 1)
#define SAMPFREQ 256                      // ADC sampling rate 256
#define TIMER2VAL (1024/(SAMPFREQ))       // Set 256Hz sampling frequency                   
#define LED1  13
#define CAL_SIG 9

// Global constants and variables
volatile unsigned char TXBuf[PACKETLEN];  //The transmission packet
volatile unsigned char TXIndex;           //Next byte to write in the transmission packet.
volatile unsigned char CurrentCh;         //Current channel being sampled.
volatile unsigned char counter = 0;   //Additional divider used to generate CAL_SIG
volatile unsigned int ADC_Value = 0;   //ADC current value

//~~~~~~~~~~
// Functions
//~~~~~~~~~~

/****************************************************/
/*  Function name: Toggle_LED1                      */
/*  Parameters                                      */
/*    Input   :  No                             */
/*    Output  :  No                                 */
/*    Action: Switches-over LED1.                   */
/****************************************************/
void Toggle_LED1(void){

 if((digitalRead(LED1))==HIGH){ digitalWrite(LED1,LOW); }
 else{ digitalWrite(LED1,HIGH); }
 
}


/****************************************************/
/*  Function name: toggle_GAL_SIG                   */
/*  Parameters                                      */
/*    Input   :  No                             */
/*    Output  :  No                                 */
/*    Action: Switches-over GAL_SIG.                */
/****************************************************/
void toggle_GAL_SIG(void){
 
 if(digitalRead(CAL_SIG) == HIGH){ digitalWrite(CAL_SIG, LOW); }
 else{ digitalWrite(CAL_SIG, HIGH); }
 
}


/****************************************************/
/*  Function name: setup                            */
/*  Parameters                                      */
/*    Input   :  No                             */
/*    Output  :  No                                 */
/*    Action: Initializes all peripherals           */
/****************************************************/
void setup() {

 noInterrupts();  // Disable all interrupts before initialization
 
 // LED1
 pinMode(LED1, OUTPUT);  //Setup LED1 direction
 digitalWrite(LED1,LOW); //Setup LED1 state
 pinMode(CAL_SIG, OUTPUT);
 
 //Write packet header and footer
 TXBuf[0] = 0xa5;    //Sync 0
 TXBuf[1] = 0x5a;    //Sync 1
 TXBuf[2] = 2;       //Protocol version
 TXBuf[3] = 0;       //Packet counter
 TXBuf[4] = 0x02;    //CH1 High Byte
 TXBuf[5] = 0x00;    //CH1 Low Byte
 TXBuf[6] = 0x02;    //CH2 High Byte
 TXBuf[7] = 0x00;    //CH2 Low Byte
 TXBuf[8] = 0x02;    //CH3 High Byte
 TXBuf[9] = 0x00;    //CH3 Low Byte
 TXBuf[10] = 0x02;   //CH4 High Byte
 TXBuf[11] = 0x00;   //CH4 Low Byte
 TXBuf[12] = 0x02;   //CH5 High Byte
 TXBuf[13] = 0x00;   //CH5 Low Byte
 TXBuf[14] = 0x02;   //CH6 High Byte
 TXBuf[15] = 0x00;   //CH6 Low Byte
 TXBuf[2 * NUMCHANNELS + HEADERLEN] =  0x01; // Switches state

 // Timer2
 // Timer2 is used to setup the analag channels sampling frequency and packet update.
 // Whenever interrupt occures, the current read packet is sent to the PC
 // In addition the CAL_SIG is generated as well, so Timer1 is not required in this case!
 FlexiTimer2::set(TIMER2VAL, Timer2_Overflow_ISR);
 FlexiTimer2::start();
 
 // Serial Port
 Serial.begin(57600);
 //Set speed to 57600 bps
 
 // MCU sleep mode = idle.
 //outb(MCUCR,(inp(MCUCR) | (1<<SE)) & (~(1<<SM0) | ~(1<<SM1) | ~(1<<SM2)));
 
 interrupts();  // Enable all interrupts after initialization has been completed
}

/****************************************************/
/*  Function name: Timer2_Overflow_ISR              */
/*  Parameters                                      */
/*    Input   :  No                             */
/*    Output  :  No                                 */
/*    Action: Determines ADC sampling frequency.    */
/****************************************************/
void Timer2_Overflow_ISR()
{
  // Toggle LED1 with ADC sampling frequency /2
  Toggle_LED1();
 
  //Read the 6 ADC inputs and store current values in Packet
  for(CurrentCh=0;CurrentCh<6;CurrentCh++){
    ADC_Value = analogRead(CurrentCh);
    TXBuf[((2*CurrentCh) + HEADERLEN)] = ((unsigned char)((ADC_Value & 0xFF00) >> 8)); // Write High Byte
    TXBuf[((2*CurrentCh) + HEADERLEN + 1)] = ((unsigned char)(ADC_Value & 0x00FF)); // Write Low Byte
  }

  // Send Packet
  for(TXIndex=0;TXIndex<17;TXIndex++){
    Serial.write(TXBuf[TXIndex]);
  }
 
  // Increment the packet counter
  TXBuf[3]++;
 
  // Generate the CAL_SIGnal
  counter++; // increment the devider counter
  if(counter == 12){ // 250/12/2 = 10.4Hz ->Toggle frequency
    counter = 0;
    toggle_GAL_SIG(); // Generate CAL signal with frequ ~10Hz
  }
}


/****************************************************/
/*  Function name: loop                             */
/*  Parameters                                      */
/*    Input   :  No                             */
/*    Output  :  No                                 */
/*    Action: Puts MCU into sleep mode.             */
/****************************************************/
void loop() {
 
 __asm__ __volatile__ ("sleep");
 
}
20  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: August 07, 2013, 10:35:19 pm
My plan is to build a data aquasition system. I'm also monitoring RPM, humidity, and amb Temp.  I am gathering information on cylinder head temperature, and carburator temperature.  To obtain the data, it sometimes needs to be attached to the aluminum itself.  The heat gradiant around the area is to great from engine to engine.  I am looking for small variations from engine to engine.  I drill a small hole on each engine and ziptie the thermocouple to the spark plug. I do this in the exact same spot each time to hopefully reduce the effects from other non related factors.  Also considering I know it can be done (since my omega meter has no problems), I just can't leave it.  The board itself can be left on a table next to it, or just far away enough not to be effected. 

21  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: August 02, 2013, 10:12:32 pm
Just found this circuit from anolog devices.  It looks like it has a low pass filter set up.  maybe I can order a demo board.
22  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: August 02, 2013, 09:37:26 pm
I understand what your saying, but I know there is some sort of solution.  I have an Omega thermocouple reader that reads the exact same thermocouple perfectly.  It has to be touching the engine to get the data I need.  I guess this problem has got the best of me so far, and I'm not going to let it win lol. 

What do the big, expensive data acquisition boxes use to deal with this problem?

It is fine to have the board far away from the engine, but the thermocouple just has to be grounded to the engine.  I'm sure building an enclosure out of mu metal would help the board, but I just cant find a good answere for the thermocouple grounding to the engine.  I took apart my omega meter.  It was hard to tell what was going on, but it uses a bunch of capacitors, resistors, and 4 transistors for 2 channels.  Maybe its some sort of flying cap design. 
23  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: August 02, 2013, 12:29:47 am
Just tested to see if the board resets without the thermocouple.  The board is fine at about 6 inches away, but when I get closer in it resets.  When i get a couple inches away from the spark plug it resets right away.  The EMF must just be crazy around the whole engine.  The board can be a couple feet away.

I'm thinking as long as the thermocouple is isolated, and references the same ground as the engine, the EMF will have the same effect on both +, and -.  This should still allow me to reed the data. 

The difference between both battery ground and engine ground must be huge! 
24  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: August 01, 2013, 07:27:12 am
I will try holding the board close to it without the thermocouple today.  I had not thought of that.  I have a screw terminal the thermocouple goes into first. No extension cable.  It will do it with a short(3 inch), or long(a couple feet), thermocouple.  They are twisted, just the normal stuff sold on a spool from omega.
I don't think it is software related.  I have ran it for hours on the bench logging data perfectly.

I added a low pass filter.  Signal going into a resistor, then to a cap, and finally to ground. I pick up the signal in between the two.  I have one for t+, t-, and engine gnd with a diode.  With this set up I had it running for 8 hours, and still no problems.  This set up just looks horrible, and I'm not even sure why it work's. 

I always here about thing being optically isolated, and figured this is why my omega temp meter can  read anything. 
25  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: August 01, 2013, 06:40:10 am
It is grounded to an aluminum cylinder head, just inches away from the coil.  Even if I hold the thermocouple a couple inches away from the metal it still resets after a period of time.  As soon as I touch any metal it resets.  I know this because I drop communication on the com port.  I have tried with multiple boards, unos, megas.  I'm all ears for any other ideas you might have. 

And once again thanks for all the help!  I still have quite a bit to learn, but this forum makes it much easier.
26  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: July 31, 2013, 08:41:23 pm
I'm glad you caught all that!  I updated it with your recomendations.

I checked the pin out on the Max6675, and 31855.  They both look to be the same, so I should be able to use either.  I already have a bunch of 6675 chips.

 I also attached the datasheet for the multiplexer.

Is it ok for the MAX chip to be on the un-isolated side?  Do you think I might end up with bad data on the Max chip still?  Can the thermocouple be isolated directly before any conditioning?

Where you seeing the same problem with your thermistor?

27  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: July 30, 2013, 05:43:44 am
I attached my design as a PDF.  Let me know what you think.  I added the multiplexer, and the tri state buffer. 
28  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: July 30, 2013, 04:48:42 am
I just spent a couple hours crawling the web, and now I see exactly what you are talking about.  I will use a tri state buffer.  I am also going to use a adg609 multiplexer, controlled by opto-couplers, to make a 4 channel input.  I will use a isothermal block to keep the compensation correct at the cold junction point.  I will post the circuit as soon as I can to get some input.
29  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: July 30, 2013, 02:38:02 am
Quote
Do you have a URL with specs for your thermocouple ?

Why do you need to isolate the thermocouple?
Jack

http://www.omega.com/pptst/IRCO_CHAL_P13R_P10R.html

It's a K Type Thermocouple.  I am reading temperatures on a small engine.  The module throws out a huge magnetic field.  Voltage builds up, and zapps the microcontroller.  I can filter it out with a low pass filter, but that's only for the one engine.  I want to be able to measure temperature anywhere.  I am kind of surprised more people have not had this problem.

Quote
You could use a modified version of the flying capacitor circuit.]

I did some research, and looks like a pretty good option.  I found the LTC1043 from Linear Technology, that is used for thermocouples. Do you know if the output could go right into the Max6675 chip, as long as I use a fast enough switching frequency?  Is it still considered an analog voltage that comes out of a circuit like this?

 
Quote
The only disadvantage is that the output pins are not 3-state.

How about using a SN74AHC1G125, and just tie OE to the CS line?


Did you use this for a thermocouple?  Also, by any chance do ya have a wiring diagram?



Thanks for all the help guys!  I know I am going to have to buy some stuff, and just start experimenting soon.  I just want to make sure I do my research so I don't throw to much money away.
30  Using Arduino / Sensors / Re: Opto-Isolator for Thermocouple on: July 29, 2013, 04:29:40 am
I just found this Isolated, ADuM5401.  I'm thinking I might be able to use this to power the Max6675, and isolate all the SPI pins.  This would totally Isolate the Max6675, and thermocouple from the microcontroller.  What do you guys think?


Pages: 1 [2] 3 4 ... 6