Show Posts
Pages: [1] 2 3 ... 22
1  Using Arduino / Networking, Protocols, and Devices / Problem connecting Pro Micro (ATmega32U4) to SD card breakout board on: May 17, 2014, 10:25:50 am
I am trying to connect an SD card to a Pro Micro.
I have  attached the 5V power (Vcc) and ground (Gnd) from the Pro Micro to the SD Card Module. 
I attached:
Pro Micro <---> SD Card Module
    10 <---> SDCS
    16 <---> MOSI
    14 <---> MISO
    15 <---> SCK

I loaded the sketch "arduino-1.0.5/libraries/SD/examples/CardInfo/CardInfo.ino"
I changed
const int chipSelect = 4;
const int chipSelect = 10;
Set Tools --> Board --> Arduino Leonardo

From the Serial Monitor I get:
Initializing SD card...initialization failed. Things to check:
* is a card is inserted?
* Is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

Has anyone connected an SD card to a Pro Micro?
2  Using Arduino / General Electronics / Re: Measuring AC mains on: May 10, 2014, 10:23:05 am
If you decide to determine power or energy quantities (kW, kWh, kVAR, kVARh) then you'll need to measure the phase (degrees). This can be determined from measuring the time interval of the Volts zero crossing to the Amps zero crossing.

I had not thought about measuring power.  I assume that I can do this is software.  If I have the (near) instantaneous voltage and current I should be able to calculate the phase.  I can detect the zero crossing of the voltage with an optoisolator, several have been presented.  However, I will probably need to detect the current zero crossing from measurements since the value could be quite low.  Although, I could  send the current sense voltage into a high gain amp to better detect the zero crossing.

Note that with transformers in the measuring circuit, there will be a phase shift from primary to secondary that you may need to account for. It depends on the accuracy you need. It varies, but this could be several degrees or more.

Where is the source of the phase shift?  Or maybe a better question is where will I observe this phase shift?  Is it in the voltage transformer while transforming the voltage from mains level to a safer 7-10 volts?  Or is it the current transformer that will give me a few millivolts for every amp measured?  Or is it a problem for both?  Is it a constant that can be canceled in software or will it need to be measured and adjusted for?
3  Using Arduino / General Electronics / Re: Measuring AC mains on: May 10, 2014, 09:54:37 am
For cost and size reasons I was leaning toward the resistors, capacitors and diodes to read the mains.  I was looking at some sort of switching power supply to power the device.  However, for safety and simplicity, I will looking into the voltage transformer method for reading the voltage and a simple linear (78L05) for power.

The ApNote from Atmel on power monitoring has a lot of good reading in it.  I only skimmed it and will need to look at it in more detail.

The web side "OpenEnergyMonitor" has projects much like what I want to do.  At least as it relates to current monitoring.  I want to see if I can find any schematics.

Thanks to everyone that responded.
4  Using Arduino / General Electronics / Measuring AC mains on: May 08, 2014, 07:03:27 pm
I want to use an Arduino to measure the Volts, Amps, and Frequency of a generator.

I  then want to be able to log or transmit that information.

For measuring the current, I was looking at a current transformer.  The transformer has a low AC voltage proportional to the current flowing through it.

To measure the frequency, I was looking as some method of watching for zero crossings.  Probably with an optoisolator.  Measure the time between crossings to find the period and take the reciprocal for the frequency.

The one that bothers me the most is the AC voltage ( and it probably applies the the current ) is how to measure the RMS voltage of the power line.  Aside from the fact that it could be tricky to get 120-240 volts down to a TTL level safely.  It may not give me the true RMS value.

Has anyone already solved this problem?
5  Using Arduino / Project Guidance / Re: i want to monitor lead acid battery using 2 current sensor to display on lcd on: May 06, 2014, 02:38:40 pm
This is my guess as to what you are trying to do.  (If I guess right, do I get a prize?)

You are trying to create a solar tracking device and check the charging results.

As mentioned earlier, I believe you only need a single ACS712 in series with the battery.  The output is Vcc/2 if no current is flowing.  It is above Vcc/2 if the current is flowing one way and below if flowing the other.  If you power the Arduino and the ACS712 then you should read 511 or 512 about half scale of 1023 values.  Therefore, you do not need your voltage divider to find the midpoint.

I assume that your tracking algorithm is independent of the solar cell output.  Therefore, unless that information is important to you, you can simply monitor the net results.  "Solar Cell Output" - "Load Consupution" = "Current Into or Out of the Battery"
6  Using Arduino / Installation & Troubleshooting / error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc on: May 03, 2014, 03:07:56 pm
Trying to upload a sketch using a USBasp programmer ( Ctrl+Shift+U ).

The IDE attempts to upload the sketch with:
/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cusbasp -Pusb -Uflash:w:/tmp/build1369312702588283912.tmp/Blink.cpp.hex:i

I received the error message
avrdude: Warning: cannot query manufacturer for device: error sending control message: Operation not permitted
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc

The problem appears to be related to permissions.  If I open a terminal window and copy and paste the command prefixing it with 'sudo' then it will work.  However, this is inconvenient. 

What is the 'official' solution?
7  Using Arduino / Programming Questions / Re: Need help creating an Object. on: April 10, 2014, 12:35:17 pm
I was attempting to define a class (or structure) that was all "static" and would not need to be instanciated.

I wanted to access the bitmap with "FONT5X8::BitMap" and not "instance5x8.BitMap"
8  Using Arduino / Programming Questions / Re: Need help creating an Object. on: April 10, 2014, 09:20:28 am
What is not allowed is to initialize the array.

An array is a pointer in C. A constant integer variable is replaced by the compiler by it's value in the resulting code. It cannot do that with the array.

That is the explanation, what is the solution?
9  Using Arduino / Programming Questions / Re: Need help creating an Object. on: April 09, 2014, 08:53:21 pm
Initialization of variables is never done in the class definition in the header file. It is always done in the source file. Any attempt to initialize variables in the class definition in the header file results in syntax errors.

There appear to me some exceptions to that.  The statement
   static const uint8_t iRows=8;
appears to be allowed.  What is not allowed is to initialize the array.
10  Using Arduino / Programming Questions / Need help creating an Object. on: April 09, 2014, 05:46:46 pm
I am trying to create an object that describes a font.  I am trying to start with something simple with a fixed pitch font but I may try to support a proportional font later.

Here is what I have.
class FONT {
    const uint8_t iRows,   iCols;
    const uint8_t iMinVal, iMaxVal;
    const uint8_t **BitMap;

class FONT5X8 : FONT {
  static const uint8_t iRows=8;
  static const uint8_t iCols=5;
  static const uint8_t iMinVal=0x41;
  static const uint8_t iMaxVal=0x5A;
  static const uint8_t BitMap[][5] = {
    {0b01111110, // 41 A       //  .@@@@@@.
     0b00010001,               //  ...@...@
     0b00010001,               //  ...@...@
     0b00010001,               //  ...@...@
     0b01111110},              //  .@@@@@@.
    {0b01111111, // 42 B       //  .@@@@@@@
     0b01001001,               //  .@..@..@
     0b01001001,               //  .@..@..@
     0b01001001,               //  .@..@..@
     0b00110110},              //  ..@@.@@.


    {0b00000111, // 59 Y       //  .....@@@
     0b00001000,               //  ....@...
     0b01110000,               //  .@@@....
     0b00001000,               //  ....@...
     0b00000111},              //  .....@@@
    {0b01100001, // 5a Z       //  .@@....@
     0b01010001,               //  .@.@...@
     0b01001001,               //  .@..@..@
     0b01000101,               //  .@...@.@
     0b01000011}               //  .@....@@

When I try to compile this, I get the error
error: a brace-enclosed initializer is not allowed here before ‘{’ token
error: invalid in-class initialization of static data member of non-integral type ‘const uint8_t [][5] {aka const unsigned char [][5]}’

So my syntax is wrong but I believe that my desire is clear.

In addition I will want to store this object in flash to preserve RAM.  However, I am looking to jump one hurdle at a time.
11  Using Arduino / Programming Questions / Re: How to determing 'Caps Lock' status on: April 09, 2014, 10:08:17 am
The keyboard itself is maintaining that status. I have an external keyboard on my notebook. If I press the caps lock key on it, the corresponding LED turns on and off. If I press the caps lock on the notebook the keyboard doesn't get any information about thats. If I hit it on both keyboards, both LEDs turn on but the computer didn't activate the functionality for any of them.
So if your Leonardo is the keyboard it has to keep track of the caps lock key usage and display the status according to the tracked usage of that key.
I do not doubt what you are seeing.  However, it is my understanding that if the status of the Caps Lock, Num Lock, ... changes, then the OS should inform all attached keyboards.  That is true if the keyboard is a PS/2 attached keyboard or a USB HID.
This may be one of those things that is not done as well as it should be.
12  Using Arduino / Programming Questions / Re: How to determing 'Caps Lock' status on: April 08, 2014, 10:54:29 am
I appreciate everyone's concern about my Caps Lock being turned on by accident.  I happen to like using my Caps Lock.

My interest is knowing the status of the Caps Lock, as well as the Num Lock, the Scroll Lock and any other status information that a keyboard (or mouse) can receive.

The communications between the keyboard and compute has always be two way, however, it don't see it in the core Arduino code.  Is it there and I am missing it?
13  Using Arduino / Programming Questions / Re: Controlling How a Library Compiles From Within a Project on: April 08, 2014, 10:47:12 am
Well actually as I pointed out, using a template design would allow selective compiling of components or debugging. And tgsuperspec pointed out how defines could select what to use in the header file. Wandered a bit off topic, however there are solutions to investigate. And neither are out of reach using the IDE.

You correctly pointed out that the use of templates allows selective compiling of the project where it is being used.  I think that templates are not that well understood and are probably underutilized.  I must confess that I never use templates.

With that said, it does not solve the problem.  The template (or #ifdef) only effect the current source file.

Let's look at the problem from a different angle.  The core library contains conditional compiled code based on hardware differences.  This makes since.  There is no effort to use templates to address this.  So now let's look at third party library.  The library to interface to Hitachi HD44780 is LiquidCrystal.  The library uses a parallel interface.  Now someone comes along and makes a board that talks I2C.  One option is to create another library, LiquidCrystal_I2C, that inherits from LiquidCrystal.  Now you have two libraries to manage.  I will grant you that when using LiquidCrystal_I2C you still need all the code for LiquidCrystal since it will still need to talk parallel to the HD44780.  So now in your project you must include the headers from both LiquidCrystal and LiquidCrystal_I2C.

This is not a perfect example, but I hope the intent is clear.
14  Using Arduino / Programming Questions / Re: How to determing 'Caps Lock' status on: April 07, 2014, 08:22:56 pm
This is close but it does not appear to be for the Leonardo using the designated 'Keyboard' class.

Is this for the UNO or Mega with the Serial interface chip flashed with the HID firmware?
15  Using Arduino / Programming Questions / Re: How to determing 'Caps Lock' status on: April 07, 2014, 02:46:46 pm
Put a light sensor over the Caps Lock LED on the keyboard & read it?
Ha Ha
Pages: [1] 2 3 ... 22