Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
echinopsis
Apr 13, 2004

by Fluffdaddy
OK I think that makes sense

Adbot
ADBOT LOVES YOU

Delta-Wye
Sep 29, 2005

Economic Sinkhole posted:

My dog bark detector/counter project is fairly successful so far, including tweeting the barks. https://twitter.com/barkbarkbarkb I ended up using an Uno and monitoring the voltage on the LED using an analog pin. The Pi runs a python script that continually monitors the serial connection and tweets when the detector hears a bark. I am thinking about trying to add audio recording in to the mix somehow, so I can confirm that it is actual barks that are setting the detector off and not other noises.

It has been a pretty fun process learning this stuff, I am excited to learn more about what I can do with Arduinos.

That thing is sexy and you are a sexy goon for making it. I am very interested in hearing more about the power arrangement on that project - I wasn't sure if you were going to have to go with batteries or something equally terrible because the unit was outside. What did you end up settling on?

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!

Sagebrush posted:

finger-detection brake that works on capacitive principles.

The shop where I work has these at almost every spot where we need a saw. I've tripped one myself, and barely had a scratch.


Bought an Arudino Micro today. I'm looking forward to doing some basic keyboard emulation soon.

Economic Sinkhole
Mar 14, 2002
Pillbug

Delta-Wye posted:

That thing is sexy and you are a sexy goon for making it. I am very interested in hearing more about the power arrangement on that project - I wasn't sure if you were going to have to go with batteries or something equally terrible because the unit was outside. What did you end up settling on?

Haha thanks. I ended up running an extension cord out to the tree to power the Pi. The Uno is running off the USB on the Pi. Not a great long term solution but I don't imagine this is a long term project.

Pics if you want them
The Uno actually fits inside the bark deterrent. I cut a slot for the USB cable.


Sophisticated waterproofing system

Dynamite Dog
Dec 12, 2012

If you're looking for something a bit easier you can get liquid electrical tape at most hardware stores.

I've been using it with shrink tube to waterproof some submerged splices and it works very well. You just paint it on and give it an hour or so to dry and harden.

Graniteman
Nov 16, 2002

I'm not having much luck with getting my arduino micro to wake up from sleep mode. I want to put my Arduino Micro into SLEEP_MODE_PWR_DOWN until pin 2 goes from low to high (RISING interrupt).

In the sketch below it all works as expected. The interrupt triggers when pin2 goes high and prints my string, so I know the interrupt works. But when I uncommented the sleep_mode() line my device goes to sleep and doesn't wake up. Now I can't even reprogram it via USB since it goes to sleep immediately, so I think I hosed up. I hope I can recover the arduino micro by using my Uno as a ISP to re-flash it but I've never done that before.

Does anyone have experience with sleep modes and waking with external interrupts who can tell me what dumb thing I am clearly doing? I'm not a new programmer, but I'm very new to electronics and this is my first real project.

code:
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h>

//define pins
const int PIR1 = 2;

void setup() {
  pinMode(PIR1, INPUT);
  Serial.begin(9600);
}

void loop() {
  Serial.print("PIR1 value: ");
  Serial.print(digitalRead(PIR1));
  Serial.print(" going to sleep: ");
  sleep();
  Serial.println(" awake!");
}

// Put the Arduino to sleep.
void sleep()
{
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  attachInterrupt(1, wakeNow, RISING);
  delay(100);
  power_adc_disable();
  // Enable sleep and enter sleep mode. Don't uncomment this or you will gently caress up your device
  // sleep_mode();
}

void wakeNow() {
  Serial.print(" wakeNow interrupt triggered");
  // When awake, disable sleep mode
  sleep_disable();
  detachInterrupt(1);
}

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

I've not done sleep mode recently, but the arduino docs seem to say you want to use attachInterrupt(0... instead of 1 for using pin 2 as the interrupt pin. 1 should map to pin 3.

Graniteman
Nov 16, 2002

TVarmy posted:

I've not done sleep mode recently, but the arduino docs seem to say you want to use attachInterrupt(0... instead of 1 for using pin 2 as the interrupt pin. 1 should map to pin 3.

That's true for an Uno, but I'm using a micro. I couldn't find clear docs for interrupts on a Micro, but I did find mention that it should be the same as a Leonardo. On a Leonardo pin 2 is on int.1.. Plus like I said, when I don't use sleep_mode() I do get the interrupt to fire correctly with the code I posted. Serial.print does send "wakeNow interrupt triggered" when pin 2 goes from low to high. So I feel like I'm using attachInterrupt correctly, but this is also the first time I'm using interrupts so I may be wrong.

TheLastManStanding
Jan 14, 2008
Mash Buttons!
It's a better practice to put the attachInterupt in the setup. I'm not sure why you're detaching it later, but you can turn them on/off with Interrupts() and noInterrupts(). You also shouldn't be using a serial command inside of your interrupt: You want the code in your interrupts to be as short and fast as possible. Having the serial command in front of the sleep_disable() is probably causing the problem as the serial command likely won't complete until the board wakes up. This page also seems to suggest that LOW is the only valid interrupt type while powered down, which means you'll need a pull up.

Graniteman
Nov 16, 2002

TheLastManStanding posted:

It's a better practice to put the attachInterupt in the setup. I'm not sure why you're detaching it later, but you can turn them on/off with Interrupts() and noInterrupts(). You also shouldn't be using a serial command inside of your interrupt: You want the code in your interrupts to be as short and fast as possible. Having the serial command in front of the sleep_disable() is probably causing the problem as the serial command likely won't complete until the board wakes up. This page also seems to suggest that LOW is the only valid interrupt type while powered down, which means you'll need a pull up.

Thanks! I was putting detach in the interrupt to keep it from firing again after the device woke up. Once I get the Micro working again I'll try it with just sleep_disable() in the interrupt function, and noInterrupts() where the main sequence resumes after waking up. I had read that page you linked but missed the part about only LOW working when the device is asleep. That's a bummer. I had actually already gotten a PCB assembled and everything was working great, except I realized that the final power consumption was too high. I started looking into the sleep mode stuff at that point. Looks like I'll need to get a new board after I finish re-prototying with sleep mode stuff working.

Woolwich Bagnet
Apr 27, 2003



Not sure if this is the right thread for this, but I'm putting together a board that is going to use an ATMega32u4 (aka leonardo) and I want it to completely ignore the power from the USB and only use external power as I'm going to be using a nice regulated power supply for it and other things. If my understanding is right, all I should need to do is tie UVCC to the other +5 V pins with the power supply. Then I can take the +5 V from the USB and have it only go to VBUS. Anyone know if this is correct?

Woolwich Bagnet fucked around with this message at 06:41 on Jul 22, 2014

Mr. Bubbles
Jul 19, 2012
I'm working on a project that uses one moteino (arduino clone with RF module) to communicate with another via RF in order to turn on/off a servo. The gateway moteino will be wired to a switch that, when thrown, transmits a 1 instead of 0, instructing a node moteino to turn on or off a servo, accordingly.


I changed the program so that the two numbers being sent are 2 and 3, and commented out the servo lines (for troubleshooting). I can still monitor the data being sent from the "gateway" moteino and confirm that '2' and '3' are being sent. Monitoring the output log of the receiving moteino, i get:

code:
Listening at 915 Mhz...
SPI Flash Init FAIL! (is chip present?)
 No signal  No signal  No signal  No signal  No signal  No signal...
 Data_Servo0 2
 invalid 
 No signal  No signal  No signal  No signal  No signal  No signal ...
 Data_Servo0 2
 invalid 
 No signal  No signal  No signal  No signal  No signal  No signal...
I've redacted some of the repeats of "No signal" to make it more forum-friendly, but you get the point.
When the switch is off, the receiving moteino gets the "2" and outputs "invalid," which is fine--however, when the switch is on, it just repeats with no signal. The output from the gateway moteino is as follows:

code:
Transmitting at 915 Mhz...
SPI Flash Init FAIL! (is chip present?)
   [RX_RSSI:-128]
Sending struct (2 bytes) 

2
   [RX_RSSI:-128]
Sending struct (2 bytes) 

2
   [RX_RSSI:-128]
Sending struct (2 bytes) 

2
   [RX_RSSI:-128]
Sending struct (2 bytes) 

3
   [RX_RSSI:-128]
Sending struct (2 bytes) 

3
   [RX_RSSI:-128]
Sending struct (2 bytes) 

3
   [RX_RSSI:-128]
Sending struct (2 bytes) 

2
   [RX_RSSI:-128]
Sending struct (2 bytes) 

2
   [RX_RSSI:-128]
Sending struct (2 bytes) 

2
As you can see, it seems to be sending a '2' or '3' without issue. So I guess the issue is on the receiving end?

I've attached the code of the programs below as well. Any idea on what may be wrong? I've posted in the moteino forums but figured I'd try here as well.

Gateway:
code:
/* Wirelessly transmit
 */

#include <RFM69.h>
#include <RFM69registers.h>
#include <SPI.h>
#include <SPIFlash.h>

#define NODEID      99
#define NETWORKID   100
#define GATEWAYID   1
#define FREQUENCY   RF69_915MHZ //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
#define KEY         "thisIsEncryptKey" //has to be same 16 characters/bytes on all nodes, not more not less!
#define LED         9
#define SERIAL_BAUD 9600
//#define ACK_TIME    30  // # of ms to wait for an ack ---- Not Currently Used.

// Ack will not be used. This is a streaming application. If a packet is lost the next servo position data
// will be accurate enough to update and move the servo.

SPIFlash flash(8, 0xEF30);                           //EF40 for 16mbit windbond chip
RFM69 radio;                                         // initiate radio object
    

 typedef struct 
 {		
   int           feederstate;                              //create transmit variable & store data potentiometer 0 data
 } Payload;
 Payload theData;                                    // create transmission package 'theData'.


// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status


void setup() 
{
  pinMode(buttonPin, INPUT);     
  Serial.begin(SERIAL_BAUD);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
  radio.setHighPower();                              //uncomment only for RFM69HW!
  radio.encrypt(KEY);
  char buff[50];
  sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);                             // Output to serial operating frequency of transceiver       
  if (flash.initialize())
    Serial.println("SPI Flash Init OK!");          // Output to serial regarding status if Flash memory exists.
  else
    Serial.println("SPI Flash Init FAIL! (is chip present?)");
}

void loop() 
{

    Blink(LED, 1000);
    // read the state of the pushbutton value:
    buttonState = digitalRead(buttonPin);

    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (buttonState == HIGH) {     
      // turn feeder on:
      Feed(3);
    } 
    else {
      // turn feeder off:
      Feed(2);
    }
    delay(1000);
}


void Feed(int feed_input)
{
    //initiate start feed command to second moteino
     // Output to serial some communications information - Data length, RSSI
    for (byte i = 0; i < radio.DATALEN; i++)
    Serial.print((char)radio.DATA[i]);
    Serial.print("   [RX_RSSI:");Serial.print(radio.readRSSI());Serial.print("]");
    Serial.println();

 // translate Pot rotation to Servo position.    
    theData.feederstate = feed_input;
  
 // Transmit payload - theData
    radio.send(GATEWAYID, (const void*)(&theData), sizeof(theData));   // transmit data to other end
       
 // Output to serial information of # bytes sent.
    Serial.print("Sending struct (");
    Serial.print(sizeof(theData));
    Serial.println(" bytes) ");
    Serial.println();
    Serial.print(theData.feederstate);
    Serial.println();
}

//void Feed(int feed_time_ms)


 void Blink(byte PIN, int DELAY_MS)
  {
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
  }
Receiving:
code:
/* Wirelessly receive */

 #include <RFM69.h>
 #include <SPI.h>
 #include <SPIFlash.h>
 #include <Servo.h>

 #define NODEID      1
 #define NETWORKID   100
 #define FREQUENCY   RF69_915MHZ                      //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
 #define KEY         "thisIsEncryptKey"               //has to be same 16 characters/bytes on all nodes, not more not less!
 #define LED         9
 #define SERIAL_BAUD 9600
 #define ACK_TIME    30                               // # of ms to wait for an ack --- Not currently used.

// Ack will not be used. This is a streaming application. If a packet is lost the next servo position data
// will be accurate enough to update and move the servo.

 RFM69 radio;                                         // initiate radio object
 SPIFlash flash(8, 0xEF30);                           //EF40 for 16mbit windbond chip
 bool promiscuousMode = false;                        //set to 'true' to sniff all packets on the same network

     //  Setup Servo Objects
 Servo Servo0;
 #define servopin         5
 typedef struct 
 {		
  int           feederstate;                                 //designate transmitted data for this potentiometer 0 value
 } Payload;
 Payload theData;

 void setup() 
 {

 // Attach Servo Objects to respective PWM pins


 // Radio initialization
  Serial.begin(SERIAL_BAUD);
  delay(100);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
  radio.setHighPower(); //uncomment only for RFM69HW!
  radio.encrypt(KEY);
  radio.promiscuous(promiscuousMode);
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);                                // Output operting frequency of transceiver
  
  if (flash.initialize())
    Serial.println("SPI Flash Init OK!");              // Print status of Flash memory
  else
    Serial.println("SPI Flash Init FAIL! (is chip present?)");
 }

 byte ackCount=0;

 void loop() 
 { 
  theData.feederstate = 2;
   //process any serial input
/*  if (Serial.available() > 0) {
    char input = Serial.read();
    }*/
      Serial.print(" No signal ");
  if (radio.receiveDone()) 
  {  
  //Output to serial information of: NodeID & RSSI  
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    Serial.print(" [RX_RSSI:");Serial.print(radio.readRSSI());Serial.println("]");
    if (promiscuousMode) 
    {
      Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
    }
	
    if (radio.DATALEN != sizeof(Payload))
      Serial.print("Invalid payload received, not matching Payload struct!");
    else
    {
      theData = *(Payload*)radio.DATA;                       //assume radio.DATA actually contains our struct and not something else

   // Print to Serial Terminal to verify RF data and Servo degree conversions.
      Serial.print(" Data_Servo0 ");
      Serial.println(theData.feederstate);
      if (theData.feederstate == 1) {
        Serial.print(" Starting to feed ");
        Serial.println();
//        Servo0.attach(servopin); 
//        Servo0.write(0);                           // Write position to servo0
      }
      else if (theData.feederstate == 0) {
        Serial.print(" Stopping feed ");
        Serial.println();
        Serial.println();
        //turn feeder off
//        Servo0.detach();
      }
      else {
        Serial.print(" invalid ");
        Serial.println();
      }
    }
    }
    
  }




 void Blink(byte PIN, int DELAY_MS)
  {
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
  }

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you

Mr. Bubbles posted:

As you can see, it seems to be sending a '2' or '3' without issue. So I guess the issue is on the receiving end?
Probably isn't your problem, but I would increase the serial rate on the receiving end. 9600 baud is about 1ms per character, which adds up quick with a lot of prints.

If you hold the send button for a long time, does the receiver still pick up 2s? When you watch the serial output, is the sender sending every 2 seconds, and is the receiver receiving every packet?

Mr. Bubbles
Jul 19, 2012
Problem solved: something was wrong with the pin #2 on my moteino; switched to a different pin and it works fine.

Mr. Bubbles fucked around with this message at 01:31 on Jul 27, 2014

TwystNeko
Dec 25, 2004

*ya~~wn*
Okay, so here's a really, really frustrating issue I've come across.

My desktop is a 64-bit machine, while my notebook is a 32-bit machine. Same OS, same versions of Arduino, same everything except for the bitness.

I'm working with the IRremote library. Even with example code, such as the IRrecvDemo, when compiled on the 64-bit machine, I get gibberish results from the IR remote - just "FFFFFFFF" results all the time.

If I take the exact same code, and compile it on the 32-bit machine, it works properly, and I get the correct results.

Note: in both cases the code runs without errors, it's just having an issue parsing the incoming data.

I've done everything I can think of - I replaced all the looser-types (int, long) in the library with the stdint.h versions (int16_t, int32_t, uint32_t, etc). No change. It compiles, runs, and reports gibberish.

I'll post code if you want - but since I'm working with examples included with the library, I think it's a moot point.

Side note: I'm using a Teensy 3.1, but as it's pretty much code-compatible, it shouldn't make a difference.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
The host/computer processor shouldn't matter since Arduino's IDE (and the changes to it to support the Teensy) pack in their own copy of the avr-gcc or other gcc compiler suite. The size of int, long, etc. will be exactly the same in your Arduino code because it's targeting the same processor (the Teensy board). I would do a fresh reinstall of the Arduino and Teensy IDE on the machine that isn't working. Gut everything already installed and install it in a new place just to be sure.

TwystNeko
Dec 25, 2004

*ya~~wn*
I've actually done that. Multiple times.

And sizeof(int) on the 64-bit machine is 4, as is sizeof(long)

On the 32-bit machine, it's 2 and 4 respectively.

Edit: I just figured out what it was. 64-bit machine - the Teensy was set to 72mhz. 32-bit was set to 96 (overclock). Switch the 64-bit machine to the 96mhz setting, and bam, it works. :suicide:

TwystNeko fucked around with this message at 22:39 on Aug 6, 2014

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass

TwystNeko posted:

And sizeof(int) on the 64-bit machine is 4, as is sizeof(long)

On the 32-bit machine, it's 2 and 4 respectively.

Sure, for code that's compiled to run on the 64-bit or 32-bit machine you should see those values. For code that's compiled to run on the Teensy sizeof(int) and sizeof(long) should never change regardless of the Arduino IDE running on a 64-bit or 32-bit computer. The Teensy's ARM processor only supports 32-bit so there's really no way for your 64-bit machine to influence the code generated for it.

plasticbugs
Dec 13, 2006

Special Batman and Robin
I'm attempting to make an internet-connected analog weather station using my Arduino Yun and an antique I got off of eBay. I want it to show the current weather conditions of my favorite places.



I think the finished product is going to be really cool, but I'm not sure how to handle controlling the temperature, barometer, and humidity gauges.

I was planning to attach the indicator arms to individual stepper motors to dial in the correct numbers. Is that the best hardware solution to this?

Also, I'm not sure how to handle what happens when the Arduino is powered down. Like if it's on 89 when it's powered down. When it powers back up and reloads the sketch, I need it to remember that it was last on 89, so on the next update from the Weather API, I can move the stepper motors forward or backward X steps to get to the correct current temperature, humidity, & barometer reading.

I guess the the program could write the current dial readings to disk on every weather update so it remembers the last temperature reading. Is that the best way to handle this?

TheLastManStanding
Jan 14, 2008
Mash Buttons!
It's bad practice to assume the stored position is correct since unexpected power failures could make that number unreliable.

If you use a servo instead of a stepper motor it will always know its position. Second option is to have something (like a contact or switch) which can be used as a home position that can be referenced on startup. Third option (and probably the best) would be to replace them with a galvanometer.

TheLastManStanding fucked around with this message at 01:50 on Aug 7, 2014

Aurium
Oct 10, 2010
I'd probably use hobby servos instead. No need to remember last position, which would simplify your program a bit.

Or you could also have an end stop switch.

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

If you want sample code and guides, amp meters hooked up to a pwm pin seem to be the most common solution to making an arduino dashboard. But I like the servo idea better. It probably comes down to whatever is easier to attach to the existing meters.

plasticbugs
Dec 13, 2006

Special Batman and Robin
I'm new to all this, so I wasn't even aware what a servo was or how it works - which I do now thanks to SA & YouTube. Thanks for the tips. I'm getting a few servos, one with full rotation to handle the barometer. I'm not sure how best to attach the needles (glue?), but I guess I'll figure that out when the servos arrive.

JawnV6
Jul 4, 2004

So hot ...

plasticbugs posted:

I'm not sure how best to attach the needles (glue?), but I guess I'll figure that out when the servos arrive.

Here: http://www.thistothat.com/

Aurium
Oct 10, 2010

plasticbugs posted:

I'm new to all this, so I wasn't even aware what a servo was or how it works - which I do now thanks to SA & YouTube. Thanks for the tips. I'm getting a few servos, one with full rotation to handle the barometer. I'm not sure how best to attach the needles (glue?), but I guess I'll figure that out when the servos arrive.

Is the full rotation one continuous rotation servo? I've not seen that term before, and googleing it only shows it at sparkfun for a continuous rotation servo. Either way, continuous rotation servos just let you set an approximate speed to spin at. They don't let you set a position to go to, so you'd have to remember or sense the position yourself, like you would with a stepper. And since they aren't granular like a stepper motor you'd have even more of a difficult time setting a precise position. If you're not certain give a link.

Also, I'm not sure why the barometer needs to spin any more than any of the other gauges. Your picture only shows it with a bit more range of motion than the other dials. A typical servo goes over 160-180 degrees which could cover almost all of the range. If you need more look for winch servos that do 1 to 3.5 turns with position control.

plasticbugs
Dec 13, 2006

Special Batman and Robin
EDIT for another question: What would you guys suggest I use to couple a hobby servo to a very thin, non-standard post (something like a needle)? The issue I'm having is that epoxying a thin needle into the exact center of the servo gear is very messy and imprecise. I looked into servo couplers, but there's nothing that would allow me to clamp down on a thin needle like a chuck of a drill clamps down on a bit. Is there something like that out there? At this point, I'm considering using a small blob of Sugru and eyeballing the placement of the needle. :suicide:

Aurium posted:

Is the full rotation one continuous rotation servo? I've not seen that term before, and googleing it only shows it at sparkfun for a continuous rotation servo. Either way, continuous rotation servos just let you set an approximate speed to spin at. They don't let you set a position to go to, so you'd have to remember or sense the position yourself, like you would with a stepper. And since they aren't granular like a stepper motor you'd have even more of a difficult time setting a precise position. If you're not certain give a link.

Also, I'm not sure why the barometer needs to spin any more than any of the other gauges. Your picture only shows it with a bit more range of motion than the other dials. A typical servo goes over 160-180 degrees which could cover almost all of the range. If you need more look for winch servos that do 1 to 3.5 turns with position control.

You're right. It is a continuous rotation servo, so I guess it won't do what I need for this project. It would be nice to have the barometer and temperature dials move through the full range - for extreme weather, but I can accept some loss on either ends. I'll look for a winch servo. Thanks for the tip!

TheLastManStanding posted:

It's bad practice to assume the stored position is correct since unexpected power failures could make that number unreliable.

If you use a servo instead of a stepper motor it will always know its position. Second option is to have something (like a contact or switch) which can be used as a home position that can be referenced on startup. Third option (and probably the best) would be to replace them with a galvanometer.

It's funny you mention the galvanometer. The Wind Speed and Wind Direction indicators on the left side of my barometer thingy are actually galvanometers (though I didn't know that's what they were called until your post). When I got the weather station, I knew it was missing an external powered weather vane - which I didn't need anyway. So I got it pretty cheap. I was hoping the entire thing was controlled through the external weather vane so I could just hook the thing up and start programming. But it turns out that the temp, humidity and barometer gauges were all controlled mechanically with little coiled bits of metal.

I experimented with sending voltage to the wires that connect to the wind indicators and was able to pin the needles with the output from the Arduino's digital out pins. Through trial and error, I found that each indicator has its own ground wire. Then, I experimented with resistors and found a solution (10K resistor) that worked for each dial. So I'm able to programmatically dial in wind speed and wind direction from the Arudino.


This is awesome. Thanks!

plasticbugs fucked around with this message at 03:58 on Aug 13, 2014

poxin
Nov 16, 2003

Why yes... I am full of stars!
So, I'm pretty crap at coding. I found an example sketch of what I'm trying to accomplish here: http://playground.arduino.cc/Learning/PhotoResistor

However I need the exact opposite behavior, aka when the photo resistor has a high value (lot of light) the LED is also bright. Each time I try to modify the code it doesn't work :smith:

Bad Munki
Nov 4, 2008

We're all mad here.


Old:
code:
 analogWrite(ledPin, analogRead(lightPin)/4)
New:
code:
 analogWrite(ledPin, 255-(analogRead(lightPin)/4))
What's going on here: analogRead() is returning a value from 0-1023. analogWrite() expects a value from 0-255. So we take the results of analogRead and divide by 4 to get the right range. That's what the first snippet does. In the second snippet, we've simply inverted the range by subtracting the result from the max.

For example: say we get "12" after reading and scaling. The first version just writes 12. The second version writes 255-12, or 243. Another example: say we read 255 after scaling. The first version writes 255, the second version writes 0. Third example: say we read 0 after scaling. First version writes 0, second version writes 255.

Bad Munki fucked around with this message at 16:34 on Aug 18, 2014

poxin
Nov 16, 2003

Why yes... I am full of stars!

Bad Munki posted:

Old:
code:
 analogWrite(ledPin, analogRead(lightPin)/4)
New:
code:
 analogWrite(ledPin, 255-(analogRead(lightPin)/4))

So with the help of this awesome goon here, we (read: he) was able to get this pretty smoothed out and working with adjustable values!

code:
int prmin = 600;
int prmax = 1000;

int lightPin = A0;
int ledPin=11;

void setup()
{
Serial.begin(9600);
pinMode( lightPin, INPUT);
pinMode( ledPin, OUTPUT );
}

void loop()
{

// input voltage on A0 of 2.5v to 3.3v, clamp and map to an appropriate range

// step 1: read A0
int val = analogRead(lightPin);
// step 2: constrain it to our expected range (based on MATH)
val = constrain(val, prmin, prmax);
// step 3: map the range [511, 675] to the range [0, 255]
val = map(val, prmin, prmax, 0, 255);
// step 4: write the result out to the pwm pin
analogWrite(ledPin, val);
// step 5: diagnostic println()
Serial.println(val);
}

plasticbugs
Dec 13, 2006

Special Batman and Robin
I'm answering my own question from above here because someone might get some use out it. I found out what I needed to couple a servo gear to a very thin (< 2mm) post. I got this and it's exactly what I needed.

TwystNeko
Dec 25, 2004

*ya~~wn*
So my latest project is a 32x32 RGB MatrixClock. One of the things I'm working on is a STL file parser, to show spinning 3D models. Simple ones, of course. The controller is a Teensy 3.1, so it's probably fast enough.

I have very janky code that does a cube / octahedron, but I'm not at all happy with it. You can see it in my GitHub here.

So far, on the parser front, I have the STL file being read in - I'm using the Binary format, as it's pretty easy to read. I just wonder if there's an easier way to handle the 3D transforms and projection than a bunch of for loops. Ultimately, I'm going to implement backface culling - which is pretty simple, just ignore the faces that are pointing away.

Anyone worked with 3D stuff?

madkapitolist
Feb 5, 2006
Has anyone tried to build this arduino sous vide?

https://learn.adafruit.com/sous-vide-powered-by-arduino-the-sous-viduino/sous-vide

Im a bit confused on what exactly to load onto the uno. I loaded the helloworld file from Adafruit_RGBLCDShield but I cannot load the actual Sous_viduino, I'm getting an error:

In file included from Sous_Viduino.ino:21:
Sous_Viduino:62: error: 'PID' does not name a type
Sous_Viduino:79: error: 'PID_ATune' does not name a type
Sous_Viduino:125: error: 'OneWire' does not name a type
Sous_Viduino:128: error: 'oneWire' was not declared in this scope
Sous_Viduino.ino: In function 'void setup()':
Sous_Viduino:178: error: 'myPID' was not declared in this scope
Sous_Viduino.ino: In function 'void Off()':
Sous_Viduino:246: error: 'myPID' was not declared in this scope
Sous_Viduino:246: error: 'MANUAL' was not declared in this scope
Sous_Viduino:262: error: 'AUTOMATIC' was not declared in this scope
Sous_Viduino.ino: In function 'void Run()':
Sous_Viduino:497: error: 'myPID' was not declared in this scope
Sous_Viduino.ino: In function 'void DoControl()':
Sous_Viduino:573: error: 'aTune' was not declared in this scope
Sous_Viduino:580: error: 'myPID' was not declared in this scope
Sous_Viduino.ino: In function 'void StartAutoTune()':
Sous_Viduino:639: error: 'myPID' was not declared in this scope
Sous_Viduino:642: error: 'aTune' was not declared in this scope
Sous_Viduino.ino: In function 'void FinishAutoTune()':
Sous_Viduino:656: error: 'aTune' was not declared in this scope
Sous_Viduino:661: error: 'myPID' was not declared in this scope

Any ideas?

madkapitolist fucked around with this message at 04:43 on Aug 25, 2014

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

I think you're missing the libraries it needs?

Here's a list from the source code:

code:
// PID Library
#include <PID_v1.h>
#include <PID_AutoTune_v0.h>
// Libraries for the Adafruit RGB/LCD Shield
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
// Libraries for the DS18B20 Temperature Sensor
#include <OneWire.h>
#include <DallasTemperature.h>
They should be somewhere on Adafruit's website. (EDIT: Here it is: https://learn.adafruit.com/sous-vide-powered-by-arduino-the-sous-viduino/downloads-and-links ) Usually, they're linked with the relevant part, and I think I saw a few links through the tutorial.

Instructions on adding Arduino libraries. Basically, if the file is a zip, you can just import it from the Arduino interface, and if it's not in a zip or you've unzipped it yourself, you can drag it into the right directory inside the Arduino directory.

madkapitolist
Feb 5, 2006
Hey thanks I just figured it out. I re-named some folders of libraries and the code didn't follow. I reverted and everything is working now. Making delicious sous vide eggs now!

http://imgur.com/a/R2FpQ

Full Circle
Feb 20, 2008

I've always been interested in the idea of making a project with an arduino or similiar but never had a need to until now, and I'm hoping I can get some advice from some knowledgeable folk.

I was recently given an old stereo amplifier (proceed AMP3) and have quickly grown tired of the fact that, if left turned on, it functions as a 150+watt heater. The only way the thing was designed to be remotely controlled was VIA their branded preamps. Luckily their manual details precisely the signal format its looking for:

REMOTE TURN-ON JACK
A 1⁄8" “mini” jack above the AC mains receptacle on the rear panel allows
remote-controlled turn-on (that is, toggling between operate and
standby) of the Proceed AMP. This remote “trigger” will be operated by a
3–12 volts DC positive-polarity pulse, of at least 100 milliseconds dura-
tion, with tip polarity as shown below:



I don't have much electrical engineering experience, however I am confident in my scripting. My current plan would be to buy a basic arduino unit, leave it permanently connected to my windows 7 media PC, and use a script to trigger the arduino to send the power signal.

Would anyone mind chiming in to tell me if an arduino is the best way of accomplishing this? The main thing that gives me hesitation is the specification for "DC positive-polarity pulse".

Thanks!

Amberskin
Dec 22, 2013

We come in peace! Legit!

Full Circle posted:


I don't have much electrical engineering experience, however I am confident in my scripting. My current plan would be to buy a basic arduino unit, leave it permanently connected to my windows 7 media PC, and use a script to trigger the arduino to send the power signal.

Would anyone mind chiming in to tell me if an arduino is the best way of accomplishing this? The main thing that gives me hesitation is the specification for "DC positive-polarity pulse".

Thanks!

It looks it could work very well. Don't forget to add a resistor to limit the current or else you could burn your arduino. The arduino works with 5V signals, so it is completely within specs.

E: for extra geek points, you could consider adding a wifi shield to the arduino so you can control it from other devices in your network.

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you

Full Circle posted:

The main thing that gives me hesitation is the specification for "DC positive-polarity pulse".
Easiest thing in the world for a microcontroller. Drive a pin high, delay 100ms, then drive low/set input. Or look back a few pages for a more proper solution than a delay.

Amberskin posted:

It looks it could work very well. Don't forget to add a resistor to limit the current or else you could burn your arduino.
I can't imagine a signal like this taking much current.

quote:

E: for extra geek points, you could consider adding a wifi shield to the arduino so you can control it from other devices in your network.
The Spark Core might be the easiest way to get this running. Just add a phone charger and an audio plug and maybe something to keep the other pins from shorting.

Full Circle
Feb 20, 2008

Thanks guys, I placed an order on Sparkfun for an arduino + relevant parts a few days ago, everything should arrive tomorrow.

Parts Kit
Jun 9, 2006

durr
i have a hole in my head
durr
I've got one of those 4x4 matrix keypads and it's nice but it eats up 8 digital pins. Would it be possible to use a shift register to send that data down to the arduino onto just the 3 or so pins it needs total? Similarly could a shift register be used to reduce the number of pins needed for operating a little LCD?

For that matter if anyone has a good link on explaining how the shift registers work in code and such that would be super awesome.

Adbot
ADBOT LOVES YOU

Amberskin
Dec 22, 2013

We come in peace! Legit!

Parts Kit posted:


For that matter if anyone has a good link on explaining how the shift registers work in code and such that would be super awesome.

There are a lot of examples in the internetz. For output you will probably want to use a 74HC595 or similar:

https://learn.adafruit.com/adafruit-arduino-lesson-4-eight-leds/the-74hc595-shift-register

If you want to multiplex inputs, you will probably want to use a digital multiplexer like the 74HC151.

http://playground.arduino.cc/Code/MUX151

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply