Recent Posts

Pages: [1] 2 3 ... 10
1
Deutsch / Re: Zeitsteuerung Vorwahlzeit
Last post by Theseus - Today at 01:33 pm
delays sind eigentlich tabu habe ich gelernt... wieso gibt´s die dann in der Prog.-Spr.? :smiley-roll-blue:
Delays sind in der Fehlersuche sehr wertvoll, wenn man einen fehlerhaften Programmteil gezielt so langsam machen kann, dass man den Fehler nachvollziehen kann.
Delays von wenigen Millisekunden helfen manchmal um auf einfache Weise das richtige Timing zu erzeugen ohne das Programm zu sehr zu verlangsamen.

Man muss sich der Wirkung von Delay bewusst sein. Kritisch wird es bei Delay oft, wenn man in den Sekundenbereich kommt, da dann der Controller nicht mehr auf Eingaben und Ereignisse reagieren kann.  
2
Deutsch / Re: relay oder netzteil?
Last post by uwefed - Today at 01:33 pm
@Uwe: Da meine zweite Heimat Sterzing ist, weiß ich genau wovon Du sprichst. In Südtirol, vor allem Bozen ist die Doppelsprache wirklich verwirrend. ;)
Die Sache wird noch schwieriger wenn man nicht Hodeutsch spricht sondern einen Dialekt.
Grüße Uwe
3
Have you tried your tester with a toggle switch in place of the MOSFET? I'm thinking about the MOSFETs rds, what type is it anyway? Also, what is the resistor wattage? Is it getting very hot?
4
Project Guidance / Re: Homemade Moonboard
Last post by TomGeorge - Today at 01:31 pm
Hi,

Quote
Hi, I'm a climber and a tinkerer.
 In many climbing gyms these days there is a device called a moonboard which is a standardized wall.
In many dozens of gyms there is one of these walls, all with the same angle and layout of holds.
This way climbers can invent a sequence of movements, upload it a phone app, and share it with over 10,000 other climbers worldwide.

The best moon boards have an RGB led under each hold, as the climber swipes through the climbs on the app, the leds indicate which holds are to be used for that particular climb.

The manufacturer of these walls sells the LED kit for $700 US.
Id like to build my own using several strings of LED pixels, and arduino as the main control, a bluetooth module to connect to the phone, and whatever other components would be necessary to build this.
From what Ive read, this shouldn't be too hard.
Im not worried about the code yet, first step is to figure out exactly what hardware I'll need.

The are 11 columns of 18 rows, so 198 total LEDs.
It seems there are several different ways off addressing that many LEDS.
In addressable LED strings there is a small microchip between each LED, and 4 wires. Two for Vcc and End, and two for communication.
From what Ive read each chip listens ti the data sent to it, turns its LED to the appropriate state, then passes the data packet to the next chip.
The downside is that the LEDs change in series rather than simultaneously.

For my project that is not a problem, as each setup is static for quite awhile before changing to the next display.

The bigger problem is that the LEDs are far to close together.
My setup will require at least 14" of separation.
I have found LED pixel strings on the net, some with 50 LEDs each.
Usually with a 6" or 8" separation.
Im not sure how to address those.
 Could I use some sort of daisy-chainable chips that let me use I2C to individually talk to 198 LEDs?

 I think that might be the cheapest method as I could buy bare RGB LEDs, as well as a huge spool of 18/4  wire.

A few MCP23008 chips should provide enough outputs if arranged properly.

a Bluetooth Module HC 05/06 or similar.

I don't know what method to use to power the array.

Any advice on a particular method to pursue, or what hardware would be best would be greatly appreciated.

Once I figure out what to buy, I'll then tackle the idea of using the moon board company's app to control a homemade system.

Since the bluetooth protocol is open source, I figure this has to be possible.

Any advice is welcome, thanks!
Sorry, needed to get it to point form to read it.
Tom..... :)
5
Deutsch / Re: Zeitsteuerung Vorwahlzeit
Last post by uwefed - Today at 01:29 pm
Delay ist nicht zu verwenden wenn in der Wartezeit etwas gemacht weden soll. Da muß die Wartezeit mittels Millis realisiert werden.

Kleine delay-Zeiten zB zum Entprellen sind (meist) unkritisch.

Grüße Uwe
6
Project Guidance / Re: Troubles using nrf24l01 to...
Last post by donraf - Today at 01:29 pm
Sorry, I thought it was working, but actually isn't.

There are my code after correct it:
Actually, nothing works. I can't send and receiver anything from each Arduino and the transmitter is printing the values really slowing.

Any idea what is wrong and what should I do to solve it?

Transmitter:
Code: [Select]
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(9, 10);

const byte addresses[][6] = {"00001", "00002"};

unsigned long lastRecvTime = 0;

String inString = "";    // string to hold input
int cd,num,pcd,rpw,vall=0;
int val01,val2,val3,val4;

String ch ="";

struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
};
struct MyData2 {
  byte altura;
 };

MyData data;
MyData2 data2;

void resetData(){
  data.throttle = 127;
  data.yaw = 127;
  data.pitch = 0;
  data.roll = 127;
}

void recvData()

  //while ( radio.available() ) {       
    radio.read(&data2, sizeof(MyData2));
    Serial.print(data2.altura);Serial.print("    ");//Serial.print("\t");
    lastRecvTime = millis();
//  }
}
void setup() {
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00001
  radio.openReadingPipe(1, addresses[0]); // 00002
  radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
  radio.setAutoAck(false);
  resetData();
  Serial.begin(115200);
  Serial.println("Ready");
}
void loop(){
 
  radio.startListening();
        readint();
        calcRPY();
        cal();
  radio.stopListening();
  radio.startListening();
  while (radio.available());
        recvData();
  radio.stopListening();
}

void readint() {
  // Read serial input:
    int inChar = Serial.read();
   
    if (isDigit(inChar)) {    inString += (char)inChar;   }
   
    if (inChar == '\n') {   cd=inString.toInt();     
      inString = "";
    }}

void calcRPY(){
  if (cd!=pcd)
 
  if(cd>0 && cd<5)              { rpw=cd; }
  else if (cd>5 && cd<1025)     { vall=cd; } 
pcd=cd;   
  }

void cal(){

switch (cd){
 case 1:
  val01=vall;
 data.throttle = map( val01, 0, 1023, 0, 255 );Serial.print("throttle=" ); Serial.print(val01);Serial.print(" yaw=" ); Serial.print(val2);Serial.print(" pitch=" );Serial.print(val3); Serial.print(" roll=" );Serial.println(val4);
 break;

case 2:
 val2=vall;
data.yaw      = map( val2,  0, 1023, 0, 255);Serial.print("throttle=" ); Serial.print(val01);Serial.print(" yaw=" ); Serial.print(val2);Serial.print(" pitch=" );Serial.print(val3); Serial.print(" roll=" );Serial.println(val4);   
 break;
 
case 3:
 val3=vall;
 data.pitch    = map( val3, 0, 1023, 0, 255);Serial.print("throttle=" ); Serial.print(val01);Serial.print(" yaw=" ); Serial.print(val2);Serial.print(" pitch=" );Serial.print(val3); Serial.print(" roll=" );Serial.println(val4); 
   break;

case 4:
val4=vall;
  data.roll     = map( val4, 0, 1023, 0, 255);Serial.print("throttle=" ); Serial.print(val01);Serial.print(" yaw=" ); Serial.print(val2);Serial.print(" pitch=" );Serial.print(val3); Serial.print(" roll=" );Serial.println(val4);   
    break;

 
  }

  radio.write(&data, sizeof(MyData));
 
  }


Receiver:
Code: [Select]
/* 
A basic receiver using the nRF24L01 module to receive 4 channels and convert them to PPM.
 */
 
#include <ServoTimer2.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <NewPing.h>
#define TRIGGER_PIN  2  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     3  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

ServoTimer2  throttleServo;
ServoTimer2  yawServo;
ServoTimer2  pitchServo;
ServoTimer2  rollServo;

////////////////////// PPM CONFIGURATION//////////////////////////
#define channel_number 6  //set the number of channels

#define sigPin_t 5  //set PPM signal output pin on the arduino
#define sigPin_y 6  //set PPM signal output pin on the arduino
#define sigPin_p 7  //set PPM signal output pin on the arduino
#define sigPin_r 8  //set PPM signal output pin on the arduino

#define PPM_FrLen 27000  //set the PPM frame length in microseconds (1ms = 1000µs)
#define PPM_PulseLen 400  //set the pulse length
//////////////////////////////////////////////////////////////////

int CH1, CH2, CH3, CH4;

int throttle, yaw, pitch, roll;

int ppm[channel_number];

//const uint64_t pipeIn =  0xE8E8F0F0E1LL;

const byte addresses[][6] = {"00001", "00002"};

RF24 radio(9, 10);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
};

struct MyData2 {
  byte altura;
};

MyData data;

MyData2 data2;

void setPPMValuesFromData()
{
  ppm[0] = map(data.throttle, 0, 255, 1000, 2000);
  ppm[1] = map(data.yaw,      0, 255, 1000, 2000);
  ppm[2] = map(data.pitch,    0, 255, 1000, 2000);
  ppm[3] = map(data.roll,     0, 255, 1000, 2000); 
  ppm[4] = 1000;
  ppm[5] = 1000;
}

void resetData()
{
  // 'safe' values to use when no radio input is detected
  data.throttle = 127;
  data.yaw = 127;
  data.pitch = 0;
  data.roll = 127;
 
  setPPMValuesFromData();
}

void setupPPM() {
  pinMode(sigPin_t, OUTPUT);
  digitalWrite(sigPin_t, 0);  //set the PPM signal pin to the default state (off)
 
  pinMode(sigPin_y, OUTPUT);
  digitalWrite(sigPin_y, 0);  //set the PPM signal pin to the default state (off)
 
  pinMode(sigPin_p, OUTPUT);
  digitalWrite(sigPin_p, 0);  //set the PPM signal pin to the default state (off)
 
  pinMode(sigPin_r, OUTPUT);
  digitalWrite(sigPin_r, 0);  //set the PPM signal pin to the default state (off)

throttleServo.attach(sigPin_t);
yawServo.attach(sigPin_y);
pitchServo.attach(sigPin_p);
rollServo.attach(sigPin_r);

}

void setup() {
  resetData();
  setupPPM();
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00002
  radio.openReadingPipe(1, addresses[1]); // 00001
    radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
  radio.setAutoAck(false);
  Serial.begin(115200);
}

void escreve_Data()

     unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
     data2.altura = map((sonar.convert_cm(uS)), 0, 1023, 0, 255 );
     Serial.print(sonar.convert_cm(uS)); Serial.print("cm");Serial.print("\t");
     radio.write(&data2, sizeof(MyData2)); 
}


unsigned long lastRecvTime = 0;

void recvData()
{       
    radio.read(&data, sizeof(MyData));
    lastRecvTime = millis(); 
    CH1=data.throttle;
    CH2=data.yaw;
    CH3=data.pitch;
    CH4=data.roll;

  Serial.print("CH1:"); Serial.print(ppm[0]); Serial.print("\t");
  Serial.print("CH2:"); Serial.print(ppm[1]); Serial.print("\t");
  Serial.print("CH3:"); Serial.print(ppm[2]); Serial.print("\t");
  Serial.print("CH4:"); Serial.println(ppm[3]);

    throttleServo.write(ppm[0]);
    yawServo.write(ppm[1]);
    pitchServo.write(ppm[2]);
    rollServo.write(ppm[3]);


  unsigned long now = millis();
  if ( now - lastRecvTime > 5000 ) {
    // signal lost?
    resetData();
  }
 
  setPPMValuesFromData();
}

void loop() {

  radio.startListening();
  if ( !radio.available()) {
    while (!radio.available()) {
                  rec vData();
    }
    radio.stopListening();
    radio.startListening();
                  escreve_Data();
    radio.stopListening();
  }
}
7
Arduino Yún / Re: Web server control of muli...
Last post by J2D2 - Today at 01:28 pm
Hi guys,
No more need to answer my above questions. Just found an other tutorial for web server LED Control/measurement integration, even easier to understand and easily modifiable. If some people are interested, this is the following one:

https://babaawesam.com/2014/11/06/control-input-output-of-arduino-yun-with-ajax/

Best regards.


J2D2
8
I am trying to create a device to flash an LED ( also an electromagnet, and a small speaker) at a known frequency and show that frequency on a LCD display. I believe I have the circuitry worked out and the basic code. It mostly does what I want but it is a little glitchy in terms of; the display seems to have a hard time keeping up at higher frequencies. ie the display flickers and doesn't print a number. Also I wonder about the accuracy of the number presented as frequency, ie have I done the math correctly.

#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int potentiometer=A0;
int potRead = 0;
int redLED = 13;
int isOn = 1;
long now = 0;

void setup(){
  pinMode(redLED,OUTPUT);
  pinMode(potentiometer,INPUT);
  digitalWrite(redLED,HIGH);
}

void loop(){
  potRead = analogRead(potentiometer);
  if(millis() > now + potRead){
    digitalWrite(redLED,isOn);
    isOn = 1 - isOn;
    now = millis();
   
    lcd.begin(16,2);
    lcd.print("potValue=");
    lcd.print(potRead);
    lcd.setCursor(0,1);
    lcd.print("frequency=");
    lcd.print(1023/potRead);
  }
}
9
Hi all,

I was wondering if I can use pinMode on analog inputs without problems.


The arduino site Arduino Site states the following :

Quote
Pullup resistors

The analog pins also have pullup resistors, which work identically to pullup resistors on the digital pins. They are enabled by issuing a command such as

  digitalWrite(A0, INPUT_PULLUP);  // set pullup on analog pin 0

Be aware however that turning on a pullup will affect the values reported by analogRead().
So my obvious questions are,

  • what then is exactly the difference between digitalWrite and pinMode
  • Is this legal as well? 
    pinMode(A0, INPUT_PULLUP);





10
Editor / Lost content of cpp file
Last post by keithmarsh - Today at 01:25 pm
Hi Everyone

This error has happened to me twice in quite a few hours of use over a number of days, so it's not a 100% repro.

I create a new class in my project, with a .h and .cpp, compiled and uploaded successfully.  I switch to another source file.  I see the editor do a full refresh on it's own, and switching back to the recent cpp, the file is completely empty and irretrievable.  :(

This has happened to me twice now.  I use chrome and firefox, and I think it's happened in both.

Has anyone else had this occur to them?

Keith
Pages: [1] 2 3 ... 10