Show Posts
Pages: 1 2 3 [4] 5 6 ... 351
46  Using Arduino / Programming Questions / Re: Delay a pin state after event on: July 18, 2014, 08:23:06 pm
Okay, just got back from shopping. Mmmmmm, cherries for $1.69/lb! Even got a bag for my neighbor.
Next I post here will be code modified from an existing example.
Input will be pin 2 grounded and output will be led 13, tested on an UNO and IDE 1.5.
Comments will be trimmed, I could spend an hour+ just there so ask about what isn't clear.

47  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 05:19:33 pm
Quote
As long as your COM channel never has errors you should be good to go without start or stop data.

How do you find the start of the first message?


I wouldn't know. It's how they roll, not me.
48  Using Arduino / Programming Questions / Re: Kind of a 'Whack a Mole' game on: July 18, 2014, 05:08:21 pm
I'm trying to find a way to make the led stay high when you push it (and when it is lid up) has anyone some good ideas? Would be great! smiley

Separate the led wiring from the button wiring at least half way.
The leds should run on abstraction of button data (logical state gotten from hardware states over time) rather than physical contact closures (hardware states).

Debounce the buttons. (logical state from hardware state over time)

Button code and led code should be separated except for variables to pass information like what button has changed and what led(s) to light or turn off.

Any code to turn button information into commands for leds (logical code) should be separate from the code for the buttons and leds (hardware code).
 
49  Using Arduino / Programming Questions / Re: Delay a pin state after event on: July 18, 2014, 04:47:39 pm
Quote
I have posted a snippet that I am trying to learn from
Then you will be needing snippets are us:-

http://snippets-r-us.com/

Priceless! Karma to you! I wish I could give you 100 Karma right now for that! And PaulS too!
50  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 04:43:07 pm
On to practical matters, now that I know you can handle more than seemed at first:

The first byte probably tells you how many bytes follow even if in an indirect way.
As long as your COM channel never has errors you should be good to go without start or stop data.

Quote
uint8_t type;
    uint8_t id;
    uint16_t pose;

or

    uint8_t type;
    uint8_t id;
    int16_t roll;
    int16_t pitch;
    int16_t yaw;

51  Using Arduino / Programming Questions / Re: string overwriting on: July 18, 2014, 04:33:53 pm
Alright, I'll switch over to char arrays. I don't really need any string functions anyhow.
Thanks

With char array you put the read character in at the index you intend.
To add characters one after the other, just increment the index each time.
Be sure to not write more characters than you have array and be sure to leave room for a 0 at the end.

The array is more direct, more open, and does not copy itself on change then delete the original as String does.
52  Using Arduino / Programming Questions / Re: Delay a pin state after event on: July 18, 2014, 04:20:29 pm
Do you want the quick and dirty code that does not debounce the button but works... that if you try and develop from there will lead to hair loss or

Do you want the code that debounces the button and is structured accomodate further development?

The first is much shorter and simpler, a way to replace a few cheap components with a far more expensive controller board.

The second makes some beginner coders cringe or run in fear while others declare joy.

Either way, I don't care. Your goals are what matters here.
53  Using Arduino / Programming Questions / Re: Data logging shield - how to wake up every 15 minutes on: July 18, 2014, 03:37:49 pm
Looking at Dead Bugs' example code now.
It seems to read sensors and put the Arduino to sleep.
When Arduino wakes up it runs the sketch, reads the sensors and goes to sleep as a virtual while loop.

The functions called are in ino files that need to be included or replaced with your own/

BTW, this could use a run through the IDE Autoformat tool for readability.

DLS_ShieldTest.ino
Code:
//-------------------------------------------------------------------------------
// This is a test sketch for the DLS 2.0 shield
// Dead Bug Protorypes
// 07.02.2014
//-------------------------------------------------------------------------------


#include <Wire.h>
#include <SD.h>
#include <OneWire.h>

#define DS1337_ADDRESS 0x68
#define ONE_WIRE_BUS 10
#define SD_CHIPSELECT 8

String strLogline = "";

void setup()
{
Serial.begin(9600);
delay(1000);
GetDate();
getTemp();
getLight();
getVolt();
WriteSD();
}

void loop()
{
while (true)
{
SetAlarm();
delay(500);
}

}

Photocell.ino
Code:
//-------------------------------------------------------------------------------
// This function will add the analog value of A0
// Dead Bug Protorypes
// 07.02.2014
//-------------------------------------------------------------------------------

void getLight(){
  int photocellReading;
 
  photocellReading = analogRead(0);
 
  strLogline += photocellReading;
  strLogline += ';';
 
}

All the parts are here, including the RTC code.
https://github.com/DeadBugPrototypes/DLS20/tree/master/DLS_ShieldTest

54  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 03:15:36 pm
Yup, thats how we roll!
Sorry your having a bad day man, but if it makes you feel better we dont have a huge budget (budgets are relative) and never had all the time in the world either...  Its a project we all volunteered to be a part of because when it gets to comicon it puts big smiles on lots of faces.... hope to see you there my friend;)

This forum has always been about sharing projects and knowledge, learning and teaching...
Makes me a bit sad to get negative vibes when I post a legitimate question, but hopefully some day Ill be the one with the knowledge and desire to both help and motivate others with similar interests.

I'm just trying to get you to reality from the situation as you painted it.

I hope your group has people who were ready already, that that first post does not indicate the team at all.

Hopefully by now you know just what 'binary data' means and can move to the next question.

Because if you haven't gotten that far, I am being very kind telling a declared non-swimmer that jumping in the middle of a deep lake is not a good way to learn how to swim. Please disregard if you are in fact a swimmer or do in fact have your own lifeguard. Otherwise hello dreamer, reality just called.

55  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 02:51:06 pm
http://video.wired.com/series/how-to-make-a-giant-robot-mech

A bunch of experts with large budget and all the tools they need look around and put together what they mostly have ready.

And you want to do that from Duh to Working in 2 days?

What really gets me is how these things are represented.
It is marketing selling expensive parts as easy-peasy, throw together like in a stupid movie.
Someone is selling kits, I'm sure, but just how complete I can't say. Is there a prize? Reputation?
56  Using Arduino / Programming Questions / Re: Using packed binary data from pc serial on: July 18, 2014, 02:41:17 pm
Hopefully this will remove the mystery of binary data.
You need to load and run the sketch with Serial Monitor open,
 then read the sketch source and compare the output on Serial Monitor.

This is only to fill in that day you all seem to have missed somehow, or your teacher did not explain or I dunno what.

If you don't get an OH moment then you either knew this already or you are denser than basalt.
If you knew this already then I can't can't figure out why your first post indicates such lack of understanding but perhaps a vitamin and/or sleep deprivation or other problem must be operating.

If you don't get it in less than 10 minutes, ask your study group or find a smart person to explain.

Code:
void setup( void )
{
  Serial.begin( 115200 );
  Serial.println( "\n What is in my variables?\n" );

  uint8_t my8bitVar = 65;
  uint16_t my16bitVar = 1234;

  Serial.print( "my 8 bit var as binary data: " );
  Serial.print( my8bitVar, DEC );
  Serial.print( " decimal = " );
  Serial.print( my8bitVar, HEX );
  Serial.print( " hexadecimal = " );
  Serial.print( my8bitVar, BIN );
  Serial.println( " binary, All The Same Value\n" );

  Serial.print( "my 8 bit var as 1 ASCII Text character: " );
  Serial.println( (char) my8bitVar );

  Serial.print( "\nmy 16 bit var as binary data: " );
  Serial.print( my16bitVar, DEC );
  Serial.print( " decimal = " );
  Serial.print( my16bitVar, HEX );
  Serial.print( " hexadecimal = " );
  Serial.print( my16bitVar, BIN );
  Serial.println( " binary, All The Same Value\n" );

  Serial.println( "Text data is ASCII characters that must be translated." );
  Serial.println( "Binary data is direct values that don't need to be translated." );

  Serial.println( "\nHere is text zero to nine, value as decimal then printed text.\n" );

  for ( my8bitVar = '0'; my8bitVar <= '9'; my8bitVar++ )
  {
    Serial.print( "my 8 bit var as decimal value " );
    Serial.print( my8bitVar, DEC );
    Serial.print( " is also the ASCII text character " );
    Serial.print( (char) my8bitVar );
  }
  Serial.println( "\n\nNote that in code, a text character in single quotes makes the ASCII value of the character." );
}

void loop( void )
{
}

57  Using Arduino / Programming Questions / Re: Delay a pin state after event on: July 18, 2014, 01:59:23 pm
The delay.... how much or little and how precise must it be?

There is likely a 555 circuit or even simpler, an R-C circuit with PNP trigger that can make such a delay.

I knew a EE student who used the latter to 'fuse' fireworks back in the 70's.

58  Using Arduino / Programming Questions / Re: Data logging shield - how to wake up every 15 minutes on: July 18, 2014, 01:49:10 pm
Isn't the shield supposed to do all that? That's what the web page says and the review seems to confirm.

59  Using Arduino / Programming Questions / Re: Active Atmel/AVR RTOS Projects? on: July 18, 2014, 03:29:00 am
Sorry. One of the big AVR draws for me is the lack of OS.


60  Using Arduino / Programming Questions / Re: Active Atmel/AVR RTOS Projects? on: July 18, 2014, 02:58:16 am
This should affect how you code on PC's as well.

Here is a master explainer/teacher, his site is a goldmine as far as software and hardware.
This is intro with working basics laid out, do not skim past the implications. Load and run and mess with the code.

Quote
How to do multiple things at once ... like cook bacon and eggs
http://gammon.com.au/blink

Quote
How to process incoming serial data without blocking
http://gammon.com.au/serial

A discussion on your specific hardware to go over what buses and devices you need to fit in would help more than just yourself and help keep you from going down dead ends. Best to cover all that up front!

Quote
The temp sensors themselves use 2 MAX31850 which depending on the resolution can take up to 750ms to read.  With an RTOS setup properly I can have other things going on while those readings are taking place. 

What interface?

I can read Serial one char at a time as it comes in but if blocks going out, really long prints can take whole msecs.
I have seen where I2C reads can block and I don't know enough about Dallas 1-wire.
Pages: 1 2 3 [4] 5 6 ... 351