Show Posts
Pages: 1 [2] 3 4 ... 11
16  Using Arduino / Sensors / Re: Arduino Mega 2560 and HacroCam on: August 28, 2013, 05:24:26 am
I tried to hook up my Hacrocam to my Mega. It didn't find the cam. I thought it might be a compatibility issue as I used it with my UNO before. But as you use it with a Mega it must be a Hardware problem. If I get it to work again I can do some testing.

And yes - the developers stopped answering requests.
17  Using Arduino / Sensors / Re: HacroCam - recalculate to greyscale before sending (processing example) on: August 28, 2013, 05:18:42 am
Nice to see that there is at least one other user with a Hacrocam!  smiley

Thanks a lot for the information. I don't have a programmer - so nothing I could test. But thanks anyway.
18  Using Arduino / Motors, Mechanics, and Power / Re: 3S lipo carger on: August 28, 2013, 04:12:12 am
Thanks for all the replies. What I then realy need is a complete Balancer and BPS - portable.
I think in this case it will be easier to build a solid five point connection for the robot and use my standard LIPO charger.
19  Using Arduino / Motors, Mechanics, and Power / Re: 3S lipo carger on: August 14, 2013, 08:10:12 am
That's why I was hoping that there is something like a multi cell lipo shield. So a balancing charger I just need to supply with two contacts.
20  Using Arduino / Motors, Mechanics, and Power / 3S lipo carger on: August 14, 2013, 01:13:42 am
Hi,

I have a Robot which is powered by a 3S/11.1 Lipo.
I would like the robot to dock to a charging station to charge its lipo.

Does somebody know a good solution for charging the Lipo with balancing? There are great Lipo shields. But they are for 1S/3.7V Lipos.

A solution with which the robot could stay on during charging would be perfect.

Thanks
Robert
21  Using Arduino / Sensors / Ultrasonic sensor with pin change interrupt on: August 06, 2013, 07:53:59 am
Hi,

as I didn't find something to copy and paste for myself I wote a sketch to use my ultrasonic sensors with pin change interrups. I share it just in case someone else searches the forum for a copy and paste ready sketch.
The sketch uses one pin only per sensor. The Ping2cm function allows to include a temperature sensor.

I used some contributed libraries and the PING2cm function is from robtillaart.
This made the whole thing easy to code.

Usage:
- Connect the echo pin of your sensor to analog 14 or 15 (both if you have two sensors).
- (doesn't work with all sensors) Connect the trigger and echo pin of your sensor to eachother (easiest is to solder them together on the front of the sensor).

All suggestions to improve the sketch are welcome.

Robert

Code:
#include <digitalWriteFast.h>
#include <PinChangeInt.h>
#include <Streaming.h>

#define endl "\n"

long StartTime = micros();
long ReceiveTime = micros();
long roundtrip = 0;
unsigned long PingTimeout = millis();
boolean PingReceived = false;
boolean triggerRunning = false;

#define NO_PORTB_PINCHANGES
#define NO_PIN_STATE
#define NO_PIN_NUMBER
#define DISABLE_PCINT_MULTI_SERVICE

#define SONAR_NUM 2
#define PingLPin  A14
#define PingRPin  A15
int PingLcm = -1;
int PingRcm = -1;
uint8_t PingCurrentSensor = 1;

#define temperature 22

void setup(){
Serial.begin(115200);
pinModeFast(PingLPin, INPUT); digitalWriteFast(PingLPin, HIGH);
pinModeFast(PingRPin, INPUT); digitalWriteFast(PingRPin, HIGH);
PCintPort::attachInterrupt(PingLPin, &echoEvent, CHANGE);
PCintPort::attachInterrupt(PingRPin, &echoEvent, CHANGE);
}

void loop(){
triggerEcho();
}

void triggerEcho(){
if (IsTime(&PingTimeout,33)){
int cm;

if (PingReceived == false){cm = -1;}
else {cm = PING2cm(roundtrip,temperature);}

switch (PingCurrentSensor)
{
case 1:
PingLcm = cm;
break;
case 2:
PingRcm = cm;
break;
}

//trigger new Ping
if (PingCurrentSensor < SONAR_NUM){PingCurrentSensor++;}
else {PingCurrentSensor = 1;}

detachPingInterrupts();
switch (PingCurrentSensor)
{
case 1:
triggerPingLPin();
PCintPort::attachInterrupt(PingLPin, &echoEvent, CHANGE);
break;
case 2:
triggerPingRPin();
PCintPort::attachInterrupt(PingRPin, &echoEvent, CHANGE);
break;
}
PingReceived = false;
triggerRunning = false;

Serial << PingLcm << " - " << PingRcm << endl;
}
}


void triggerPingLPin(){
pinModeFast(PingLPin, OUTPUT);
digitalWriteFast(PingLPin, HIGH);
delayMicroseconds(8);
digitalWriteFast(PingLPin, LOW);
pinModeFast(PingLPin, INPUT); digitalWriteFast(PingLPin, HIGH);
}

void triggerPingRPin(){
pinModeFast(PingRPin, OUTPUT);
digitalWriteFast(PingRPin, HIGH);
delayMicroseconds(8);
digitalWriteFast(PingRPin, LOW);
pinModeFast(PingRPin, INPUT); digitalWriteFast(PingRPin, HIGH);
}

void echoEvent(){
if (triggerRunning == false){
StartTime = micros();
triggerRunning = true;
}
else{
ReceiveTime = micros();
roundtrip = ReceiveTime - StartTime;
PingReceived = true;
}
}

boolean IsTime(unsigned long *timeMark, unsigned long timeInterval) {
if (millis() - *timeMark >= timeInterval) {
*timeMark = millis();
return true;
}   
return false;
}

uint32_t PING2cm(uint32_t duration, int t)
{
uint32_t x = t+55;
x = x + (x>>1) + (x>>2) + (x>>5);
x = x + 915;
x = x * duration;
x = (x >> 1) + (x >> 5) + (x >> 8) + (x >> 9);
x = x >> 15;
return x;
}

void detachPingInterrupts(){
PCintPort::detachInterrupt(PingLPin);
PCintPort::detachInterrupt(PingRPin);
}
22  Using Arduino / Sensors / NewPing - last bit of performance on: July 23, 2013, 08:47:50 am
Hi,

first - big thanks for this fantastic library. I used it in two projects so far. Works perfectly.
With my new project I am pushing the Arduino Mega to its limits. I need to drive two steppers - that's the time critical part.
When I enable the pings (using the timer from the 15 sensor example) they sometimes start to stutter as it can't keep the step frequency. As far as I can see it's when the distance to ping is high. If I hold my hand in front of the sensor it's much better.

I went through all the rest of my code. No delays (all implemented as FSM) and no unnecessary complicated calculations.

So I thought it might be possible to get out the last bit of performance with direct addressing of the pins (http://forum.arduino.cc/index.php/topic,46896.0.html) and with an alternative solution on the micros delays in newPing::ping_trigger()
But it is above my capabilities. I assume if it would be simple it would be in the library  smiley-lol

Does someone see an “easy” to implement approach? Or am I on the wrong track at all?

Thanks
Robert
23  International / Deutsch / Re: Pololu A4988 mit AccelStepper? on: July 12, 2013, 01:09:45 am
Hallo,

ja, funktioniert. Habe ich so im Einsatz.
Accelstepper unterstützt Steppertreiber mit DIR uns STEP pin.

Gruß´
Robert
24  Using Arduino / Motors, Mechanics, and Power / Re: 12v - stepdown or directly via Arduino? on: July 11, 2013, 12:18:05 am
Yes, it's a robot. I started switching to the dc-dc converter for 5V.
The 3.3v for the XRF http://ciseco.co.uk/downloads/documents/datasheet%20-%20XRF%20v1-6.pdf I get from the arduino mega, backed up with a cap. It's within specs (36ma when sending). Setting up an own converter just for this conflicts with the space limitations I have on the robot. But when I need to hook up more 3.3v devices, I'll need to do the switch anyway.

Thanks Robert
25  Using Arduino / Motors, Mechanics, and Power / 12v - stepdown or directly via Arduino? on: July 10, 2013, 02:20:33 am
Hi,

I use a 12v power supply (3S lipo). I drive 2 stepper dirvers, 3x Ultrasonic, 2x IR sensor and 1x XBee (directly via 3.3V). I may add more later.
Till now the 800ma max (http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations) should be more than enough. --> in theory
I have three clocked step down supplies lying around.

From your point of view, does it make sense to:

1)   Keep everything as it is (most simple)
2)   Step down 12V to 7V and keep supplying everything via the arduino
3)   Step down 12V to 5V supply and supply the sensors and stepper drivers from this supply. Keep the 12V supply for the arduino.
4)   Better idea?

Thanks
Robert
26  Using Arduino / Sensors / Re: tsop4838 - constant signaling on: July 04, 2013, 01:03:27 pm
OK, I now do it like this:

Code:
#define IRledPin 3

void setup (){}

void loop() {

  for(int i = 0; i <= 10; i++) {
    digitalWrite(IRledPin, HIGH);
    delayMicroseconds(13);
    digitalWrite(IRledPin, LOW);
    delayMicroseconds(13);
  }
  delayMicroseconds(3000); // sometimes the sensors don't resync if the delay is shorter
}


It works. But certainly isn't the optimum.

If someone has a better idea or other experience which may help .. it's very welcome.

Thanks
Robert
27  Using Arduino / Sensors / tsop4838 - constant signaling on: July 04, 2013, 02:00:16 am
Hi,

I am building an IR beacon and a receiving sensor for my robot.
I built the sender out of five IR LEDs a transistor and some caps.

As receiver I want to use two IR Receivers TSOP4838(http://www.produktinfo.conrad.com/datenblaetter/150000-174999/171115-da-01-en-IR_EMPFAENGER_MODUL_TSOP_4838__VIS.pdf) in tubes to get a directional sensor. (need to find the correct angle between them so they both receive if pointed directly to the beacon)
To not produce too much overhead and to get a (timing wise) steady signal I do not want to decode any IR remote signals. I just count rising or falling signals on external interrupt pins as long as I need the sensor. Then I compare the results from both sensors.

So far sender and both receivers work as long as I use the IRremote library for sending valid IR remote signals. When I simply generate a 38kHz modulated signal, the receivers seem to give up after some time. As far as I read that’s part of the logic for noise filtering.

What is required to bypass this and keep the sensors constantly outputting signals? I think it can be concluded from the statements at the end of page 5. But I have difficoulties stranslating it into code.
Especially combining the modulation and the signaling. I think I don't get very far here with the tone library.

Thanks
Robert

Code of the receiver/sensor:
Code:
volatile long counter0 = 0;
volatile long counter1 = 0;
long wait = millis();
long countexp0 = 0;
long countexp1 = 0;

void setup()
{
  Serial.begin(115200);
  attachInterrupt(1, count1, FALLING);
  attachInterrupt(0, count0, FALLING);
  pinMode(2,INPUT_PULLUP);
  pinMode(3,INPUT_PULLUP);

}

void loop()
{
  if (millis() - wait > 100){
  countexp0 = counter0;
  countexp1 = counter1;
  counter0 = 0;
  counter1 = 0;
  
  Serial.print(countexp0);
  Serial.print(",");
  Serial.println(countexp1);

  wait = millis();
  }
}

void count1()
{
  counter1++;
}
void count0()
{
  counter0++;
}

The sender code which works:
Code:
#include <IRremote.h>

IRsend irsend;

void setup()
{}

void loop() {
      irsend.sendRC6(0xa90, 50);
}

Code of the sender with only the modulated signal (it will be a dedicated sender, so no fancy things with timer or interrupts are needed):
Code:
void setup ()
{
tone (3, 38000);
}
void loop () {}
28  Using Arduino / Programming Questions / Re: simultaneous interrupts - what will happen on: June 28, 2013, 09:22:37 am
I'll use a mega. Should have stated that. So I go for the hardware timer.

Again. Thanks.
29  Using Arduino / Programming Questions / Re: simultaneous interrupts - what will happen on: June 28, 2013, 07:26:49 am
Thanks for the swift response!
30  Using Arduino / Programming Questions / simultaneous interrupts - what will happen on: June 28, 2013, 07:11:21 am
Hi,

I am thinking about how to best build a directed IR receiver for finding the direction of a beacon.

I tried one 38 khz IR receiver in a tube. Not bad but still about 10° angle for receiving.
So I plan to test with 3 receivers, each in its own tube. One in the middle, the others a few degrees to the right and left.

As the output of the receivers is digital I need to count pulses over time to see which get triggered the most.
I plan to attach each receiver to an interrupt pin on the mega and count the pulses during a specific amount of time.

As all receivers get triggered from the same beacon they most likely output their signal at the same time (well - practically).

The main question:
What happens to the two interrupts which (should) get triggered while the routine for the first interrupt pin increases the hit counter?

Or is there a better way to implement this?

Thanks
Robert
Pages: 1 [2] 3 4 ... 11