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
Delta-Wye
Sep 29, 2005
You'll probably need a large motor with an encoder, but that isn't a bad plan.

Check out Sparkfun's Robotics 101 videos, especially the first few on angular and linear motion https://www.sparkfun.com/videos/. They're pushing their robotics hardware pretty hard, but the concepts are universal and you may find a few of their items are exactly what you need.

Adbot
ADBOT LOVES YOU

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you
Is there a place to order small servos that's a little more like Digikey than Sparkfun? Or should I just find the model I want and then search Ebay and Google?

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

Captain Cool posted:

Is there a place to order small servos that's a little more like Digikey than Sparkfun? Or should I just find the model I want and then search Ebay and Google?

I would check RC or hobby stores, they usually have tons of different servos: http://www.hobbyking.com/hobbyking/store/__84__189__Servos_Parts-All_Servos.html

Captain Cool
Oct 23, 2004

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

mod sassinator posted:

I would check RC or hobby stores, they usually have tons of different servos: http://www.hobbyking.com/hobbyking/store/__84__189__Servos_Parts-All_Servos.html
Thanks. I did see some hobby stores come up on Google but I didn't get that one.

I was also checking dealextreme since I'm making an order there anyway, and, um,

Only registered members can see post attachments!

Bad Munki
Nov 4, 2008

We're all mad here.


Maybe pololu? They're sort of sparkfun-y but more focused on robotics and have a pretty healthy selection of servos and related gear.

http://www.pololu.com

Amberskin
Dec 22, 2013

We come in peace! Legit!

Captain Cool posted:

Thanks. I did see some hobby stores come up on Google but I didn't get that one.

I was also checking dealextreme since I'm making an order there anyway, and, um,



This is another chinese DX-like site:

http://www.banggood.com/buy/servo.html

I have never bought anything from them, though.

Amberskin
Dec 22, 2013

We come in peace! Legit!
Is there any reason to get an UNO instead of a Leonardo? I own a micro (Leonardo based) and I'm thinking about getting a normal form Arduino.

Acid Reflux
Oct 18, 2004

Captain Cool posted:

Thanks. I did see some hobby stores come up on Google but I didn't get that one.

I was also checking dealextreme since I'm making an order there anyway, and, um,



I have a whole pile of those. If all you need is a cheap, light duty servo for small projects they'll fit the bill quite nicely.

Captain Cool
Oct 23, 2004

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

Acid Reflux posted:

I have a whole pile of those. If all you need is a cheap, light duty servo for small projects they'll fit the bill quite nicely.
I was referring to the typo on the label in that picture. Doesn't give me high hopes of getting a genuine product.

Mantle
May 15, 2004

Amberskin posted:

Is there any reason to get an UNO instead of a Leonardo? I own a micro (Leonardo based) and I'm thinking about getting a normal form Arduino.

The uno allows you to remove and replace the microcontroller if you want to prototype your project into a standalone product.

poeticoddity
Jan 14, 2007
"How nice - to feel nothing and still get full credit for being alive." - Kurt Vonnegut Jr. - Slaughterhouse Five

Mantle posted:

The uno allows you to remove and replace the microcontroller if you want to prototype your project into a standalone product.

It's worth mentioning that there are some Unos that have an SMD microcontroller, which while technically removable, would be a tremendous pain to deal with.

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

Amberskin posted:

Is there any reason to get an UNO instead of a Leonardo? I own a micro (Leonardo based) and I'm thinking about getting a normal form Arduino.

If you have a micro I would go for the Leonardo then since it will have the same features.

Acid Reflux
Oct 18, 2004

Captain Cool posted:

I was referring to the typo on the label in that picture. Doesn't give me high hopes of getting a genuine product.

Doh! Completely missed that. Had to go check mine, they actually say "servo." :)

Amberskin
Dec 22, 2013

We come in peace! Legit!

mod sassinator posted:

If you have a micro I would go for the Leonardo then since it will have the same features.

Yeah, that is my intention. Just wondering if there was something I was not seeing about the UNO.

Sagebrush
Feb 26, 2012

There are some differences in the way the serial port is handled on the Uno vs. the Leonardo, and the Uno has the removable microcontroller, but that's about it. The Uno has the really annoying and poorly designed type-B USB port too.

If you want to program a discrete chip, though, you don't need an Uno to do it. Just buy the plain old chip (ATMega328 in 28-pin PDIP) from Mouser or DigiKey and wire it up with the ArduinoISP sketch (google it) and you're good to go. You can also program ATTiny85, 2313 and a few others this way.

Sagebrush
Feb 26, 2012

Captain Cool posted:

I was referring to the typo on the label in that picture. Doesn't give me high hopes of getting a genuine product.

If you buy cheap servos from a site in China it is virtually guaranteed that you are not getting a "genuine product." What you get may be equally functional or even come off the same production line, but it is definitely a ripoff in one way or another.

PS. Love the cabin
Dec 30, 2011
Bee Lincoln
I get this weird thing every now and then after uploading new code to my Uno.
My debug messages sometimes come out with the first few characters garbled in the beginning.

code:
Port closed
Uploading to I/O board
Port open
?????????q1????qY5????q??????q	?????q?????????????q???q??????????????cpp->line 82: Initialized and ready to go!
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 69: Button down
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 71: Button released
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 69: Button down
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 71: Button released
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 69: Button down
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 71: Button released
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 69: Button down
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 71: Button released
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 69: Button down
C:\Users\ooo_000\AppData\Local\VMicro\Arduino\Builds\Fadewithbutton\uno\Fadewithbutton.cpp->line 71: Button released
About 20% of the time the first line is garbled, everything after that comes out just fine.
It's harmless but a bit odd.

Sagebrush
Feb 26, 2012

Is your serial port set to the correct baud rate?

PS. Love the cabin
Dec 30, 2011
Bee Lincoln
Yeah, both the arduino and serial monitor are set to 9600bps.
It works most of the time but the odd time the first few dozen bytes end up garbage.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
I've seen garbage like that if the serial port is open when the Arduino is restarted. I think it might have to do with the bootloader--for a short period of time while the Arduino is loading up it looks for any attached programmer and might be sending some junk on the serial port.

Doublethink
Sep 11, 2001

Umpossible my dear fellow, simply umpossible
I've also seen similar when there was too much of a draw or the power was lovely.

Captain Cool
Oct 23, 2004

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

mod sassinator posted:

I've seen garbage like that if the serial port is open when the Arduino is restarted. I think it might have to do with the bootloader--for a short period of time while the Arduino is loading up it looks for any attached programmer and might be sending some junk on the serial port.
I think it might be the other way around. If you send a message immediately after startup, the serial hardware might not have had enough time to get stable power or clock or something. That could mangle the first few bits, which could throw off the receiver for a while. The serial protocol doesn't have much redundancy, and with certain kinds of data it might take a while before your data stops looking like start and stop bits.

Bad Munki
Nov 4, 2008

We're all mad here.


Also, it bears mentioning that opening the serial monitor in the arduino environment resets the arduino and you'll often see garbage output left over from that.

Amberskin
Dec 22, 2013

We come in peace! Legit!
Just a heads up. Some days ago I asked about reasons to choose an UNO over a Leonardo. Now I have one: the Leonardo bootloader eats 4KB of flash memory, while the UNO uses just half kilobyte. I'm trying to drive a LCD using this library http://henningkarlsen.com/electronics/library.php?id=51 and the demo programs just don't fit in the Leonardo. They are about 30KB in size, while the leonardo available flash is about 28K.

I'm pretty sure there are smaller libraries around (and I think I would be able to strip down UTFT to make it fit), but looking at the price of the arduino compatible boards sold by chinese manufacturers I'm just getting an UNO (and a mega to be able to use 16 bit addressing for the TFT).

Bad Munki
Nov 4, 2008

We're all mad here.


Anyone here tried playing with the CapacitiveSensor library? I'm having trouble getting it to work. I'm just using the example sketch, but all I ever get is -2. I tried upping the timeout to as much as 8 seconds, no change. I've got a 1MΩ resistor from pin 2 to 4, and a wire going to a copper pad on pin 2. The pad is about 1 square inch, on the end of about 12" of wire. The resistor is on the low end from what I've read, but still within range. I also tried a 47kΩ resistor, no change. And three 1MΩ resistors in series, no change. not sure if it matters but I'm doing this on a teensy 3.0. I feel like I should at least get SOMETHING besides that error code as long as I have it wired up right. And I've checked and re-checked the pins according to the pinout chart from pjrc, scroll down to Teensy 3.0 pins, I'm using Digital Pins 2 and 4.

Any ideas? :(

Fortunately, I have a backup plan for this, but I probably should have made a proof of concept before I designed and ordered a board based on this working. :v:

Kasan
Dec 24, 2006

Bad Munki posted:

Anyone here tried playing with the CapacitiveSensor library? I'm having trouble getting it to work. I'm just using the example sketch, but all I ever get is -2. I tried upping the timeout to as much as 8 seconds, no change. I've got a 1MΩ resistor from pin 2 to 4, and a wire going to a copper pad on pin 2. The pad is about 1 square inch, on the end of about 12" of wire. The resistor is on the low end from what I've read, but still within range. I also tried a 47kΩ resistor, no change. And three 1MΩ resistors in series, no change. not sure if it matters but I'm doing this on a teensy 3.0. I feel like I should at least get SOMETHING besides that error code as long as I have it wired up right. And I've checked and re-checked the pins according to the pinout chart from pjrc, scroll down to Teensy 3.0 pins, I'm using Digital Pins 2 and 4.

Any ideas? :(

Fortunately, I have a backup plan for this, but I probably should have made a proof of concept before I designed and ordered a board based on this working. :v:

I just did this yesterday! I ended putting the resistor on the output pin instead of the sense pin.

For added fun inline the resistor with the out put and airgap the sense wire and see how close you get your hand.

--------------
I2C - or how an arduino is going to kill me. I'm on a kindle so I'll bare minimum this.

Connections:
arduino uno pin 5 to MCP23008 pin 1
Uno pin 4 to mcp pin 2
4.7k pull ups on both

Mcp pins 3,4,5 to GND (0x20 device address) also pin 9 (chip gnd)
mcp pin 6 (reset) to 5v also pin 18 (vcc)
Mcp pin 9 (gp0) to and led in series with a 220ohm resistor then into ground.

_---------------
The problem. I'm unable to get the led to ever turn on. Ive been working with example code from the wire library references. One migrane later i'm asking for help.

theperminator
Sep 16, 2009

by Smythe
Fun Shoe
I've got MCP23017s which are similar, and an Uno but never used them with each other so I can't speak for how the libraries work

But do the examples say to use pins 4 and 5? because there are dedicated I2C SCL and SDA lines on the top left hand side of my arduino.
:edit: I've looked it up and yeah the A4 and A5 lines are i2c also so you've probably wired it up right in that sense

Can you post a sample of the code you're using?

theperminator fucked around with this message at 10:22 on Mar 26, 2014

Bad Munki
Nov 4, 2008

We're all mad here.


Kasan posted:

I just did this yesterday! I ended putting the resistor on the output pin instead of the sense pin.

For added fun inline the resistor with the out put and airgap the sense wire and see how close you get your hand.

So it must be something I'm doing wrong. Even if I swapped where the sensor was, I would still expect to see something besides the -2 error code on the output. I wonder if there's some difference between the arduino and the teensy that make this library not work as expected. I'll have to dig out an old arduino to see if I can get it going with that.

Sagebrush
Feb 26, 2012

If you're using A4 and A5, they have internal pull-ups, so the 4.7ks might not be necessary. I've used I2C for communication between two Arduinos and never needed external pull-ups.

e: actually between one arduino and one Teensy 2.0. I have no idea if the Teensy 3 has a similar setup or what.

Amberskin
Dec 22, 2013

We come in peace! Legit!

Sagebrush posted:

If you're using A4 and A5, they have internal pull-ups, so the 4.7ks might not be necessary. I've used I2C for communication between two Arduinos and never needed external pull-ups.

e: actually between one arduino and one Teensy 2.0. I have no idea if the Teensy 3 has a similar setup or what.

You have to enable the pullups in your code though:

code:
pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors
Source: http://forum.arduino.cc/index.php/topic,5313.0.html

Sagebrush
Feb 26, 2012

Looking at Wire.cpp I found this line

code:
        // On Teensy 3.0 external pullup resistors *MUST* be used
	// the PORT_PCR_PE bit is ignored when in I2C mode
	// I2C will not work at all without pullup resistors
	// It might seem like setting PORT_PCR_PE & PORT_PCR_PS
	// would enable pullup resistors.  However, there seems
	// to be a bug in chip while I2C is enabled, where setting
	// those causes the port to be driven strongly high.
	CORE_PIN18_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
	CORE_PIN19_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
So it automatically enables the pullups on A4/A5 for all of the Arduino-likes, but I guess the Teensy 3.0's MCU either doesn't have the internal pullups or there's a bug.

Kasan
Dec 24, 2006
Well I managed to solve my own question after staring at my code, example code, tutorials that have nothing to do with what I was trying to do beyond using I2C and the datasheet for the MCP23008. Turns out my problem was I didn't understand register addressing even remotely. (horray for beginners)

An example code block would be something like.

code:
#include <Wire.h>

void setup() {
  Wire.begin();
}

void loop(){
  Wire.beginTransmission(0x20); //Start talking to the I2C device at location 32
  Wire.write(0x00); //Talk to the IODIR register to change input/output state
  Wire.write(0x00); //Set IODIR as OUTPUT
  Wire.endTransmission();

  Wire.beginTransmission(0x20);
  Wire.write(0x09); //Talk to the GPIO Register (part of the problem I had)
  Wire.write(0x01); //Set the IO Pins to 0000001 (Pin 10 is High, 11->17 are Low)
  Wire.endTransmission();
  delay(500);
  
  Wire.beginTransmission(0x20);
  Wire.write(0x09);
  Wire.write(0x00); //Set pins 10-17 Low
  Wire.endTransmission();
  delay(500);
}
This correct code (Commented with what I discovered) turns an LED located off pin 10 on and off every half second. Going hog wild with new found knowledge, I made Pins 10-16 turn on and off in sequence, forward and reverse with LEDs every 1/8th of a second. (I was a Knight Rider fan, sue me). Going even further, I hooked up a second MCP23008 to make the end lights blink of and on 25 times using a while loop (my first one!). I encountered a problem with this though. With the twice devices hooked up in paralell, both devices ceased to function like I expected they would. It turns out with both chips trying to be outputs at the same time, nothing wanted to work. I couldn't tell you why, but I'm sure somebody here or in the electronics thread probably could. The solution was to turn one chip into an output set and one to an input set depending on which device was needing to do something important at the time. That was done by fliping the 0x00 set to a 0x00 ; 0xFF. This still had some issues, to which I was told I needed to set the input'd chip into a "high impedance state" but my instructor couldn't really explain why (I know more than he does on the subject which leaves me pretty lacking when I have questions). I did it by writing to register 0x06 and setting everything High (and then low again after I was done writing), and it worked like I expected everything to. It was a ton of lines of code but extremely satisfying when I finally got it working at 1am, which class meeting 7 hours later. (Who needs sleep when there is science to be done.)

The end result is a new problem that I wasn't able to figure out. How do I write to pin 17? It's listed in the date sheet as GPO7, but to address it I would need to use 8 bits, and the chip only allows the writing of 7 bits (the 8th bit being a directional bit that's automatically set from the IODIR register.) How I do use this elusive bit and make full use of the 8 I/O pins?

Circuit porn:

theperminator
Sep 16, 2009

by Smythe
Fun Shoe
Regarding the last paragraph, I don't think that's right. I have no idea what you're talking about re: 8th bit.

If you want to set pin 17 high it should be as simple as writing 0x80 to the IO Register. i.e

Wire.beginTransmission(0x20);
Wire.write(0x09);
Wire.write(0x80);
Wire.endTransmission();
delay(500);

CygnusTM
Oct 11, 2002

SparkFun is having a big sale for Arduino Day this Saturday. Great time to pick up a couple of cheap boards if you need them.

Hadlock
Nov 9, 2004

I picked up a Sainsmart Uno with the 328 chip for $11 shipped the other day, shipped from Hong Kong in about 8 days. It blinks and does all the basic stuff you would expect it to

http://www.sainsmart.com/sainsmart-uno-atmega328p-pu-atmega8u2-microcontroller-for-arduino.html

Also, nVidia announced their Jetson TK1 board, it's sort of like a turbocharged Beagle Board, it't $192; basically a DIY chromebox

https://developer.nvidia.com/jetson-tk1

Tegra SOC, Kepler GPU + ARM Cortex A15
2GB ram, 16gb onboard storage, SD card, multiple USB, full size HDMI, dedicated audio jacks, gig-e, tons of GPIOs and a couple PWM pins

127mm x 127mm

Hadlock fucked around with this message at 04:07 on Mar 28, 2014

Amberskin
Dec 22, 2013

We come in peace! Legit!

Hadlock posted:

I picked up a Sainsmart Uno with the 328 chip for $11 shipped the other day, shipped from Hong Kong in about 8 days. It blinks and does all the basic stuff you would expect it to

http://www.sainsmart.com/sainsmart-uno-atmega328p-pu-atmega8u2-microcontroller-for-arduino.html



I got yesterday my order from banggood, with an UNO R3 for 8.51€ and a Mega2560 for 11.39€. Wait time: aproximately 15 days.

http://www.banggood.com/Wholesale-Arduino-SCM-And-3D-Printer-Acc-c-2153.html

Acid Reflux
Oct 18, 2004

CygnusTM posted:

SparkFun is having a big sale for Arduino Day this Saturday. Great time to pick up a couple of cheap boards if you need them.

Everything is (unsurprisingly) already sold out on the site, but they're allowing backorders. Pro Minis are only $3.00!

jovial_cynic
Aug 19, 2005

Hey folks. I just picked up my first arduino a couple of days ago after trying to figure out the best way to accomplish some in-car indicator projects.

I've got coding background (Perl, VB), and as a few people have said in the thread previously, going from on-screen results to in-world results is something magical. I'm not sure why I didn't get into arduino years ago when I first heard about it.

Anyhow, my first project was to tear apart the Blink tutorial that comes w/ the software and make a little 5-LED Knight-Rider light array.

The code is just an array holding the pin identifiers, a couple of for-loops that cycle through the LEDs, and that's basically it.


SPOILER ALERT: Don't get too excited before you click on it. It's nothing that will be mounted in a car at this stage. It's just a proof of concept.


https://www.youtube.com/watch?v=o6oFqNHbDlU


This is so much fun, though.

Kasan
Dec 24, 2006

Private video is private. :smith:

Adbot
ADBOT LOVES YOU

Sagebrush
Feb 26, 2012

jovial_cynic posted:

Anyhow, my first project was to tear apart the Blink tutorial that comes w/ the software and make a little 5-LED Knight-Rider light array.

The code is just an array holding the pin identifiers, a couple of for-loops that cycle through the LEDs, and that's basically it.

Are you using the delay() function or timers? delay() is bad because the command literally just sleeps the entire CPU for n milliseconds so you can't do anything else in the meantime. A better method is

code:
long timer;
int delay = 50; //50 millisecond timer delay

void loop() {
  if (millis() > timer + delay) {
    //do a thing
    timer = millis();
  }
}

This way the CPU keeps on running while the timer is going, and the computational load is very low. timer is a long type because the standard Arduino int is a signed 16-bit value, which will only get you up to 32.7 seconds before the timer overflows and breaks. I think there's also a way to fire a timer interrupt if you need microsecond-precision timing. If you're already using a method like this, ignore and carry on.

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