| Arduino Forum ::  Members :: point5
 Show Posts Pages: 1 [2] 3 4 ... 19
 16 Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 02:39:39 pm PS, this is the I2C request and response:
 17 Using Arduino / Programming Questions / Bit stuck on bit manipulations ? on: February 28, 2014, 02:29:44 pm Hi,Wondering if I may ask for a little help with this bit maniulation problem?I have an I2C sensor which returns 4 bytes but I need to extract 14 bits from the first two and 11 bits from the second two:Byte 1: 00101100 //use last 6 bitsByte 2: 11001101  //use all 8 bitsByte 3: 01011100 //use all 8 bitsByte 4: 11100000 //use first 3 bitsAiming for:Byte1 + Byte2 = Value 1: 10110011001101 = 11469 in Decimal&Byte3 + Byte4 = Value 2: 01011100111 = 743 in DecimalMy code currently looks like this but not sure how to manipulate the bits to get the above format correct?The byte values returned at the moment are (values should be different to the example above):PMSB = 10100000PLSB =  100TMSB = 1011011TLSB = 1110100Code:  int value 1;  int value 2;  byte PMSB;  byte PLSB;  byte TMSB;  byte TLSB;  Wire.beginTransmission(0x50);  Wire.endTransmission();  Wire.requestFrom(0x50,4);  PMSB = Wire.read();  PLSB = Wire.read();  TMSB = Wire.read();  TLSB = Wire.read();  value1 = ((PMSB << 8) | PLSB);  value2 = ((TMSB << 8) | TLSB);
 18 Using Arduino / Programming Questions / Re: Date/Time for RTC as seconds since 1/1/2000 on: December 10, 2013, 04:12:32 pm Well I think your right, hacking the Library like this will trip me up in the future - I would prefer to set those register bits from the sketch but really not sure how to do that?
 19 Using Arduino / Programming Questions / Re: Date/Time for RTC as seconds since 1/1/2000 on: December 10, 2013, 03:55:20 pm Hi Crossroads,Thanks, I will look at that.  Also, looking at the datasheets it looks as if there are some alarm modes which are not implemented in the Library such as 'When Minutes Match' & 'When Minutes and Seconds Match' - this would suffice as I could just increment minutes and seconds and not worry about what happens to hours, day, months etc - So if I understand right I have modified bit 7 in the registers below to enable 'When Minutes and Seconds Match' - might be a bit of a rough code edit but it could work :-)Code://Enable HH/MM/SS interrupt on /INTA pin. All interrupts works like single-shot countervoid DS3231::enableInterrupts(uint8_t hh24, uint8_t mm, uint8_t ss){    unsigned char ctReg=0;    ctReg |= 0b00011101;     writeRegister(DS3231_CONTROL_REG, ctReg);     //CONTROL Register Address    writeRegister(DS3231_AL1SEC_REG,  0b00000000 | bin2bcd(ss) ); //Clr AM1    writeRegister(DS3231_AL1MIN_REG,  0b00000000 | bin2bcd(mm)); //Clr AM2    writeRegister(DS3231_AL1HOUR_REG, (0b10000000 | (bin2bcd(hh24) & 0b10111111))); //Clr AM3    writeRegister(DS3231_AL1WDAY_REG, 0b10000000 ); //set AM4}
 20 Using Arduino / Programming Questions / Date/Time for RTC as seconds since 1/1/2000 on: December 10, 2013, 12:45:26 pm Hi,I have been using the nice DS3231 RTC along with this library https://gist.github.com/jeje/2021145 I would like to be able to set the alarm interupt with the number of seconds since 1/1/2000, ie the starting date for this RTC as reported by this function:  Code:Serial.print(now.get(),DEC);The Alarm is currently set by this function which uses hours, minutes and seconds:Code: RTC.enableInterrupts(18,4,16); //ie 18:04:16Is there a clever coder out there who may guide me on how to write a function that uses Seconds since 1/1/2000 to set the alarm?  This would very simply allow me to query the current time with Code:now.get and then add a number of seconds and set the alarm - the nice thing about this would be that all the roller-overs of minutes and hours would be taken care of :-)The Code:RTC.enableInterrupts(18,4,0); code from the library that I would like to change to Code:RTC.enableInterrupts(440003968); Code://Enable HH/MM/SS interrupt on /INTA pin. All interrupts works like single-shot countervoid DS3231::enableInterrupts(uint8_t hh24, uint8_t mm, uint8_t ss){unsigned char ctReg=0;ctReg |= 0b00011101;writeRegister(DS3231_CONTROL_REG, ctReg); //CONTROL Register Address writeRegister(DS3231_AL1SEC_REG, 0b00000000 | bin2bcd(ss) ); //Clr AM1writeRegister(DS3231_AL1MIN_REG, 0b00000000 | bin2bcd(mm)); //Clr AM2writeRegister(DS3231_AL1HOUR_REG, (0b00000000 | (bin2bcd(hh24) & 0b10111111))); //Clr AM3writeRegister(DS3231_AL1WDAY_REG, 0b10000000 ); //set AM4}
 21 Using Arduino / Sensors / Re: TSYS01 - function to read temperature...... on: December 02, 2013, 04:46:35 pm Thanks DC42, much appreciated.Thanks for pointing out my way too small variable - I really didn't spot that one   Yip, that datasheet needs correcting doesn't it - well spotted, I will email them.  I have my CSB and PS tied as you describe but I'm still not getting good responses - I do get something back which is a start I guess.I will keep plugging away and post back some code here when I get this working - cheers.
 22 Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: November 28, 2013, 05:53:18 pm Yip, this new MCU looks great, Arduino could do with a nice low-power option for battery powered applications - I will keep watching with interest.  I have used Tindie from the UK before so count me in for a nice 841 low power board :-)
 23 Using Arduino / Sensors / Re: TSYS01 - function to read temperature...... on: November 28, 2013, 02:35:38 pm Still chipping away at this :-)I'm now wondering if this is something to do with Arduino WIRE using 7 bits and this device using 8 bits - could this be the issue, can I still use this sensor with the Arduino WIRE library and if so how ?This is what the byte structure looks like:Cheers
 24 Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: November 28, 2013, 09:10:11 am Hi, will this new MCU be supported by the Arduino IDE?  Thanks.