Pages: 1 [2]   Go Down
Author Topic: Development using Arduino...  (Read 956 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 210
Posts: 13030
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Only two bytes are needed.  Use two bits to indicate the range and the remaining 14 bits to store the value...

0.01 to 9.99 --> value * 100 is stored
10.0 to 99.9 --> value * 10 is stored
no decimal from 100 to 10,000 --> value * 1 is stored

The drawback is the value has to be decoded and you absolutely cannot try to store negative values or values over 16,385 (meaning you need to include the clamps).

This should get you started...

Code:
union
{
  typedef struct
  {
    uint16_t range:2;
    uint16_t value:14;
  };
  uint16_t storeThis;
}
cracker_t;

As long as you only write to range / value and only read from storeThis you should be OK with strict aliasing rules.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But what about time stamp?

Also, Why does the Arduino Mega not use FTDI? Is there a limitation there?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 210
Posts: 13030
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, Why does the Arduino Mega not use FTDI? Is there a limitation there?

It makes the board more versatile.  You can reconfigure the board to be different USB devices (e.g. the board can be presented to the computer as a keyboard).
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 545
Posts: 27358
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

10,000 decimal is only 0x2710, could be stored as an INT.
1000 values only needs 2000 bytes to store.
Then add another INT with # of seconds since start, 65,535 = 1092 minutes = 18 hours. Is that enough?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It makes the board more versatile.  You can reconfigure the board to be different USB devices (e.g. the board can be presented to the computer as a keyboard).

Does this make the board native USB? So instead of a virtual com port the computer will recognize the board as a USB device? Like when you plug in a digital camera, it'll say "Sony DSCXXX" or when you plug in a phone it'll say the brand and model number?

Can I still use good old FTDI instead?

Quote from: CrossRoads
10,000 decimal is only 0x2710, could be stored as an INT.
1000 values only needs 2000 bytes to store.
Then add another INT with # of seconds since start, 65,535 = 1092 minutes = 18 hours. Is that enough?

Actually, no. I need a RTC, that'll display time and date info on the screen at all times. And at the click of a button the current reading should be stored along with the time and date info. It'll be rolling list, so when the user gets to reading number 1000, it would automatically start again from reading number 1.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 545
Posts: 27358
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd go with external SPI interface part then, either EEPROM or FRAM (ferro-electric RAM; has SRAM access speeds, EEPROM data retention but without the write limitations/byte. Mouser.com has a good variety of them). Store as much as you want per logged event.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 545
Posts: 27358
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I use FTDI in my projects.  No messing with additional programming of 16U2 part for a USB interface.
I add a socket to plug one of these in and not mess with soldering the TSSOP package down:
http://www.mouser.com/ProductDetail/mikroElektronika/MIKROE-483/?qs=%2fha2pyFadugsEwyLV5fFyIWdPbushEDhRSvnBE0ODG8%3d


* MIKROE-483usb_uart.jpg (17.26 KB, 600x240 - viewed 5 times.)
« Last Edit: March 13, 2013, 09:14:16 am by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 210
Posts: 13030
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Does this make the board native USB?

"Native USB"?  That's an odd phrase.

Quote
So instead of a virtual com port the computer will recognize the board as a USB device?

Virtual com ports are a particular type of USB device.  But I understand what you mean.

Quote
Like when you plug in a digital camera, it'll say "Sony DSCXXX" or when you plug in a phone it'll say the brand and model number?

Exactly.  On this forum, MIDI and HID (keyboard or mouse) seem to be the most commonly mentioned USB devices.  It is possible to mimic any USB device (e.g. storage, camera, joystick).

Quote
And at the click of a button the current reading should be stored along with the time and date info.

A range of days with a granularity of one second.  If two bytes is used the range is about 3/4 of a day.  Three bytes gets a range of 194 days.

Two bytes for the value plus at least three bytes for the time-offset with at least 1000 values stored means you have exceeded the available EEPROM.  It's time to shop for a FRAM.

...oh, wait...  Are you going with the 2560 or the 1284?
« Last Edit: March 14, 2013, 02:19:47 pm by Coding Badly » Logged

Pages: 1 [2]   Go Up
Jump to: