Show Posts
Pages: [1] 2 3 ... 19
1  Using Arduino / Programming Questions / Re: Sketch Size too close for comfort :-) on: April 23, 2014, 01:00:08 pm
Hej GoForSmoke , wondering what sort of numbers are good and bad when reported by your freeRam (); function?  Ta
2  Using Arduino / Programming Questions / Re: Sketch Size too close for comfort :-) on: April 23, 2014, 09:57:34 am
Hey Folks,

Many thanks indeed - now shaved 700 bytes off the compile thanks to recycing the Array used to convert the numbers to chars (thanks wildbill).... moving over to checking RAM now :-)
3  Using Arduino / Sensors / Re: Help! How to use ADT7420 with Arduino on: April 23, 2014, 07:12:59 am
Hi,

Its not often I get to contribute a solution but I'm slowly leanring so can perhaps start putting something back :-)

Here is my sketch to read the ADT7420.... enjoy

Code:
#include <Wire.h>

#define ADT7420Address 0x48
#define ADT7420TempReg 0x00
#define ADT7420ConfigReg 0x03
long tempReading = 0;
float temp;

void setup()
{Serial.begin(9600);
Wire.begin();
Serial.println("Starting....");}

void loop()
{   readADT7420();
    delay(1000); }

void readADT7420()
{
  Wire.beginTransmission(ADT7420Address);
  Wire.write(0x03);
  Wire.write(B10100000); //Set 16bit mode and one-shot mode
  Wire.endTransmission();
  delay(250); //wait for sensor
 
  byte MSB;
  byte LSB;
  // Send request for temperature register.
  Wire.beginTransmission(ADT7420Address);
  Wire.write(ADT7420TempReg);
  Wire.endTransmission();
  // Listen for and acquire 16-bit register address.
  Wire.requestFrom(ADT7420Address,2);
  MSB = Wire.read();
  LSB = Wire.read();
  // Assign global 'tempReading' the 16-bit signed value.
  tempReading = ((MSB << 8) | LSB);
  if (tempReading > 32768)
  {tempReading = tempReading - 65535;
  temp = (tempReading/128.0)*-1;}
  else
  {temp = (tempReading/128.0);}
  Serial.print("Temperature: ");
  Serial.println(temp,2);
}
4  Using Arduino / Programming Questions / Sketch Size too close for comfort :-) on: April 23, 2014, 07:06:58 am
Hi,

I'm working on a little project which is now too big :-)..... Binary sketch size: 30,720 bytes (of a 30,720 byte maximum).

I suspect this is going to cause me problems when the code is running so I have a couple of questions:

- How many bytes should one really have spare at the end of compile to be safe?
- I suspect the code below can be optimised to skip the arrays I'm using to convert from floats but not sure how?

Any pointers appreciated as always.

Code:
char packetBuffer [60] = {};
    ltoa (nodeRTC, nodeRTCArray, DEC);
    dtostrf(eTS, 0, 2, eTSArray);
    dtostrf(eTA, 0, 2, eTAArray);
    dtostrf(eRH, 0, 2, eRHArray);
    dtostrf(eSR, 0, 2, eSRArray);
    dtostrf(bat_voltage, 0, 2, eBMArray);
    dtostrf(RTCbat_voltage, 0, 2, eBCArray);
   
    strcat(packetBuffer, nodeRTCArray);
    strcat(packetBuffer, ":");
    strcat(packetBuffer, eTSArray);
    strcat(packetBuffer, ":");
    strcat(packetBuffer, eTAArray);
    strcat(packetBuffer, ":");
    strcat(packetBuffer, eRHArray);
    strcat(packetBuffer, ":");
    strcat(packetBuffer, eSRArray);
    strcat(packetBuffer, ":");
    strcat(packetBuffer, eBMArray);
    strcat(packetBuffer, ":");
    strcat(packetBuffer, eBCArray);
5  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: March 01, 2014, 05:48:27 am
Marvellous, thanks for explaining - that's incredibly useful, I can't believe I didn't know how to do that ;-)

Have a good weekend.
6  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: March 01, 2014, 04:23:48 am
You have of course cracked this - thank you again.

So I understand..... putting 'float' at the start of the calculation effectively converts any ints in the formula to floats?
7  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: March 01, 2014, 04:10:10 am
Hmmm, I have one more question which is very odd to my eyes but I am doing something simple wrong :-)

When I evaluate the following code temp returns a value of -46 whereas it should be 18.45 according to my calculator?  I guess I need to do this differently.....

Code:
float temp;
int tempCount = 701;
temp=(((tempCount*200)/2048)-50);
8  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 06:47:46 pm
Star - thank you :-)

I've learnt alot tonight - cheers.
9  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 06:25:27 pm
Sorry, I'm not completely following how this works.... however

The result should be with the bits we need to use in BOLD:
Binary values are those recieved, Binary values in BOLD are those to use and HEX values from the Binary values to use:
BYTE1 0x20 = 10100000
BYTE2 0x04 = 00100000
Gives 0010000000000100 = 0x2004

&

BYTE3 0x5B = 01011011
BYTE4 0xC0 = 11010100
Gives 01011011110 = 0x2DE

10  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 05:53:59 pm
Almost :-)

int Pressure = (B_1 << smiley-cool | B_2;
is correct and gives 0x2004

int Temp = (B_3 << smiley-cool | B_4;
isn't correct and should give 0x2DE ?
11  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 05:36:45 pm
Hi,

Here is my code, on an Arduino 328:
Code:
 int tempReading = 0;
  int pressureReading = 0;
  int PMSB=0x0;
  int PLSB=0x0;
  int TMSB=0x0;
  int TLSB=0x0;

  Wire.beginTransmission(0x50);
  Wire.endTransmission();
  Wire.requestFrom(0x50,4);
  PMSB = Wire.read();
  PLSB = Wire.read();
  TMSB = Wire.read();
  TLSB = Wire.read();

  PMSB = (PMSB & 0x3F);
  TLSB = (TLSB & 0xE0);
  pressureReading = (PMSB + PLSB);
  tempReading = (TMSB + TLSB);
12  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 05:17:59 pm
Thanks for helping out folks - I'm very close to seeing this working now....

My 4 BYTES come in as:
1: A0
2: 04
3: 5B
4: D4

I can mask them thansk to you folk giving:
1: 20
2: 04
3: 5B
4: C0

No the problem comes when I try to join BYTE1 to BYTE2 & BYTE3 to BYTE4

I should get the following answer:
1+2 = 0x2004
3+4 = 0x2DE

With this code I get the wrong answer for some reason?

Code:
INT pressureReading = ((BYTE1*256) + BYTE2);
INT tempReading = ((BYTE3*256) + BYTE4);
13  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 03:24:13 pm
Cool - I understand how that works :-)

I now have this but alas no joy yet:

Code:

  PMSB = Wire.read();
  PLSB = Wire.read();
  TMSB = Wire.read();
  TLSB = Wire.read();

  PMSB = (PMSB & 00111111);  //Mask off first two bits
  TLSB = (TLSB & 11100000);  //Mask off last five bits
  pressureReading = ((PMSB*256) + PLSB);  //Shift PMSB left 8 bits and add PLSB as INT
  tempReading = ((TMSB*256) + TLSB);  //Shift TMSB left 8 bits and add TLSB as INT
 
14  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 03:06:21 pm
.... fab - may I ask how I would mask these bytes please  smiley-red
15  Topics / Science and Measurement / Re: SODAQ - a nice Arduino Low Power Wireless Data Logging Project on: February 28, 2014, 02:44:25 pm
No news yet - I think we will have them soon :-)
Pages: [1] 2 3 ... 19