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
Trabisnikof
Dec 24, 2005

General_Failure posted:

Hey people!
Sorry to do a tl;dr on you, but I intend on reading this thread fully when it's a little more useful to me. For that I need some help. I'm looking to buy a cheap Arduino like thing from AliExpress or similar. Honestly I don't really know what I'm looking for.
I'm coming to you from "the other side". Not death, but I've always designed built my own boards and written my own firmware but would like something cheap and cheerful to throw at things when I need to quickly solve a temporary problem.
I have one right now that I've brought up in the blue smoke thread. I need something to drive a stepper for an egg tray in an incubator. That's just one example though. Pretty much just random data logging, sensing and actuating stuff.

I'm not a brand whore. Ie don't care about architecture family etc. but decent toolchain support in Linux is a big plus.

Could someone please point me in the right direction? I'd like to order one and one of those big packs of 30-ish daughterboards they have ideally. I'm doing this on a budget of as close to $0 as possible.

Could someone please offer some suggestions on things that work? Thanks. I've looked and I'm kind of daunted.

I like the attiny85 (and the general attiny series) for small and cheap. If you're already down to program hardware you can get i2c/twi working alright. People even drive lcd displays with them, just without a frame buffer.

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Sagebrush posted:

They're easy to manufacture because there is already an industry set up to do so in high volumes. The processes and techniques, and even the actual manufacturing steps to be taken, are already established, and only the specific dimensions need to be changed.

Consider another example: successful injection molding is objectively a difficult and complicated process, but it's so commonly used and well understood today that McDonald's toys can use it.

You made another great example of something that, in the quantity of the number of mail sorters you're probably going to sell per year, is extremely expensive. The molds are 10s-100s of thousands of dollars. My point is, if you arent making hella mail sorters its extremely expensive. An automotive camshaft is dirt cheap. 30 camshafts that cant be made by an automotive cam grinding shop because of length and tooling is very expensive.

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

General_Failure posted:

Hey people!
Sorry to do a tl;dr on you, but I intend on reading this thread fully when it's a little more useful to me. For that I need some help. I'm looking to buy a cheap Arduino like thing from AliExpress or similar. Honestly I don't really know what I'm looking for.
I'm coming to you from "the other side". Not death, but I've always designed built my own boards and written my own firmware but would like something cheap and cheerful to throw at things when I need to quickly solve a temporary problem.
I have one right now that I've brought up in the blue smoke thread. I need something to drive a stepper for an egg tray in an incubator. That's just one example though. Pretty much just random data logging, sensing and actuating stuff.

I'm not a brand whore. Ie don't care about architecture family etc. but decent toolchain support in Linux is a big plus.

Could someone please point me in the right direction? I'd like to order one and one of those big packs of 30-ish daughterboards they have ideally. I'm doing this on a budget of as close to $0 as possible.

Could someone please offer some suggestions on things that work? Thanks. I've looked and I'm kind of daunted.

Do you deal a lot with modern ARM Cortex M0 chips? If so check out the Arduino M0 Pro: https://www.adafruit.com/products/2417 It's an Atmel SAMD21G18 processor which is an ARM Cortex M0 running at 48mhz and with 256kb of flash memory and 32kb of RAM. You can use GCC to program it and Atmel has a pretty nice set of libraries (called ASF) for dealing with the peripherals. You can also program it really easily from the Arduino IDE if you just want to get some code running on it.

If you don't need something that powerful then you can't go wrong with a typical Arduino Uno or compatible. Like Adafruit's metro (https://www.adafruit.com/products/2488), Sparkfun's red board (https://www.sparkfun.com/products/12757), etc. Those compatible boards are a little cheaper but have the exact same Atmel ATmega328p chip that runs at 16mhz with 32kb of flash memory and 2kb of RAM. You can find even cheaper boards on ebay, etc. but it can be a crap shoot if they're any good--better to buy from a known distributor to prevent a lot of aggravation. With these boards you can program them from the Arduino IDE, or you could setup avr-gcc to do your own firmware.

IMHO if you typically work with more powerful chips I would skip the Uno/ATmegas and go straight to the M0. I've worked with both boards a lot and the M0's ARM core is really nice and much easier to work with compared to the ATmega. You can even go in and do step by step debugging with GCC or Visual Studio/Atmel Sudio using the M0 and its EDBG chip.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


General_Failure posted:

Hey people!
Sorry to do a tl;dr on you, but I intend on reading this thread fully when it's a little more useful to me. For that I need some help. I'm looking to buy a cheap Arduino like thing from AliExpress or similar. Honestly I don't really know what I'm looking for.
I'm coming to you from "the other side". Not death, but I've always designed built my own boards and written my own firmware but would like something cheap and cheerful to throw at things when I need to quickly solve a temporary problem.
I have one right now that I've brought up in the blue smoke thread. I need something to drive a stepper for an egg tray in an incubator. That's just one example though. Pretty much just random data logging, sensing and actuating stuff.

I'm not a brand whore. Ie don't care about architecture family etc. but decent toolchain support in Linux is a big plus.

Could someone please point me in the right direction? I'd like to order one and one of those big packs of 30-ish daughterboards they have ideally. I'm doing this on a budget of as close to $0 as possible.

Could someone please offer some suggestions on things that work? Thanks. I've looked and I'm kind of daunted.

You just need to drive a stepper.

I went onto amazon, found something that ships prime, and hit go. I see a $.90US one on there. I think mine were $10 for 3, and they're fine.

Use four pins from that and four transistors in an h-bridge to drive your stepper. Done. Solved problem. The arduino IDE works in linux.

Of course, you could also just get a stepper driver breakout (pololu, a4988, etc), and wire up a 555 to throw a pulse at that thing's "step" pin every so often, with some limit switches to switch between forward and reverse.

babyeatingpsychopath fucked around with this message at 01:19 on Jan 14, 2016

General_Failure
Apr 17, 2005

babyeatingpsychopath posted:

You just need to drive a stepper.

I went onto amazon, found something that ships prime, and hit go. I see a $.90US one on there. I think mine were $10 for 3, and they're fine.

Use four pins from that and four transistors in an h-bridge to drive your stepper. Done. Solved problem. The arduino IDE works in linux.

Of course, you could also just get a stepper driver breakout (pololu, a4988, etc), and wire up a 555 to throw a pulse at that thing's "step" pin every so often, with some limit switches to switch between forward and reverse.

Didn't realise there were actual breakout boards. What's this something you are speaking of? Also I'm in Australia so Amazon doesn't always work out so well for me.

Anyway I went on to Aliexpress and overdid it a little.
Bear in mind I'm talking generic here.
2xNano v3.0
Mega Sensor Shield v2.0 for R3 (I know it just reshuffles pins but it's useful)
2.4" TFT touch panel (Been dreaming of something like this since the Gameboy came out)
A couple of different temp / humidity sensors
a case for an Uno R3
RTC module (I swear I have one somewhere already but no idea where)
Mega 2560 compat. board
Uno R3 compat. board
120 pcs DuPont line (desperately needed)

Should get me started.

More of a blue smoke thing, but I worked out my old PIC programmer is a JDM, found software for it, found the programming cable I made out of a D9 serial mobo connector, the few remaining stragglers of jumper wire, and a PIC7F747. Shoved the PIC and wires into the corroded old breadboard I dug up, turned on the programmer with the 7+ year old 9v battery, opened the programming software in Win10 and actually talked to the PIC. Feels good to be back.

Looking forward to getting my stuff from far flung corners of China now.

e:
Sorry forgot the other reply.
Power doesn't concern me too much. I usually use uCs for repetitive tasks or things that it isn't worth my time working out proper logic for. I'd love to play with an ARM based board, but I couldn't justify the price. I've been an ARM advocate since it surfaced.

General_Failure fucked around with this message at 12:18 on Jan 14, 2016

Sagebrush
Feb 26, 2012

CarForumPoster posted:

You made another great example of something that, in the quantity of the number of mail sorters you're probably going to sell per year, is extremely expensive. The molds are 10s-100s of thousands of dollars. My point is, if you arent making hella mail sorters its extremely expensive. An automotive camshaft is dirt cheap. 30 camshafts that cant be made by an automotive cam grinding shop because of length and tooling is very expensive.

Who do you think buys mail sorters? Hint: they aren't super concerned with the up-front cost of the machine.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Sagebrush posted:

Who do you think buys mail sorters? Hint: they aren't super concerned with the up-front cost of the machine.

I know I am being an annoying douche about this but I think you're talking out of your rear end. I'm going to drop the non arduino chat. Im curious what kind of engineer you are, though. I am a mechanical experienced in CNC machining and at one point, this was my garage:



Id like to know your background since you seem to be an expert on mail sorter camshaft manufacturing cost.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


General_Failure posted:

Didn't realise there were actual breakout boards. What's this something you are speaking of? Also I'm in Australia so Amazon doesn't always work out so well for me.

Look at stepper driver boards. They're commonly available on 3d printer sites. The commonest are Pololu-brand A4988s and pin-compatible clones using other driver chips. You feed in stepper motor voltage (12V, 24V, 9V, whatever), logic voltage (3.3 or 5V), then you assert three pins to make the thing go: Enable, Direction, and Step. Every pulse on the "step" pin moves the motor one step in "direction" if "enable" is on. The board handles current limiting and all kinds of other great stuff to make these braindead simple to use. There are typically jumpers on the board to enable 1/2, 1/4, or 1/8 microstepping for the A4988s, and 1/16 and possibly 1/32 stepping for other chips. This means if you've got a 200steps/rototation motor and you jumper the board for 1/8 microstepping, you get to send 1600 pulses to get one revolution. Downsides are more current draw and lower total torque.

Sagebrush
Feb 26, 2012

CarForumPoster posted:

I know I am being an annoying douche about this but I think you're talking out of your rear end. I'm going to drop the non arduino chat. Im curious what kind of engineer you are, though. I am a mechanical experienced in CNC machining and at one point, this was my garage:

Id like to know your background since you seem to be an expert on mail sorter camshaft manufacturing cost.

I'll drop it too, but to answer your question I am a university professor of industrial design and I run a rapid prototyping and CNC manufacturing lab.

General_Failure
Apr 17, 2005

babyeatingpsychopath posted:

Look at stepper driver boards. They're commonly available on 3d printer sites. The commonest are Pololu-brand A4988s and pin-compatible clones using other driver chips. You feed in stepper motor voltage (12V, 24V, 9V, whatever), logic voltage (3.3 or 5V), then you assert three pins to make the thing go: Enable, Direction, and Step. Every pulse on the "step" pin moves the motor one step in "direction" if "enable" is on. The board handles current limiting and all kinds of other great stuff to make these braindead simple to use. There are typically jumpers on the board to enable 1/2, 1/4, or 1/8 microstepping for the A4988s, and 1/16 and possibly 1/32 stepping for other chips. This means if you've got a 200steps/rototation motor and you jumper the board for 1/8 microstepping, you get to send 1600 pulses to get one revolution. Downsides are more current draw and lower total torque.

That's really good. Current limiting is a really big bonus.

By the way I haven't abandoned the project. I finished it off today. It was plagued by weird hardware and software problems but in the end it worked. I unceremoniously shoved the electronics in a cardboard box with a USB cable sticking out one side for power and the stepper cable out the other. I set the uC to run at 32kHz, and the stepper is being driven with 20ms pulses with approx. 2 sec between pulses. No danger of anything overheating. it's working fine.

Really looking forward to getting the stuff I ordered after that mess.

huhu
Feb 24, 2006
Are there any good online courses that talk about Arduino and electrical engineering? Or two separate courses? I'm a bit experienced with both but rusty and I'd like to get caught back up to speed and learn some new stuff. I've looked a little bit at MIT OCW but think it might be a bit much.

One Legged Ninja
Sep 19, 2007
Feared by shoe salesmen. Defeated by chest-high walls.
Fun Shoe
I'm looking for opinions/advice. I'm working on a flight simulator radio stack, that consists of 8 rotary encoders (which I could have simplified by only using one, and then having a selector switch, but that's beside the point.), around 20 buttons, and 12, eight digit, 7-segment displays. I'm currently using a Mega2560. The seven segment displays are all prebuilt MAX7219-based boards, that I have daisy chained in two series of six. I currently have the displays and the encoders communicating with FSX, through Link2FS, and things work as they should.

I'll readily admit that I know very little about programming, and only a little more about electronics. What I do know I've mostly taught myself, so it's been slow going.

I decided it would be a good time to try to learn about matrices, so after what seemed like days of beating my head against a wall, I finally have a working circuit on a breadboard. (Seriously, the worst thing about getting older is feeling like I'm getting dumber.) But now what I'm finding is that I can't think of a fast way to A) turn each button press into the correct serial print without having a big switch case, and B) have each button press only register once until I release the button.

A) is because I'm running it all through for loops, and B) is because I poll each row of switches one at a time, and every time I run through the loop, it counts as a new press.

I could write a switch case to solve A) by cross checking row and column values, then printing out the appropriate value. It just seems like there should be a more elegant way.

B) I'm not as sure about. If I create a variable to track whether the button was pressed last time through the loop, I'd need one for each button, or an array of an array of variables.

I also thought about writing each switch's value to a single bit in a three byte variable, and then using that to tell the sim which button(s) is/are being pressed, but I'm hitting a mental block trying to learn about bitmasks and such.

I'm concerned about each of these things taking too long. The encoders need somewhat good response times to work smoothly. I haven't timed the matrix loop yet, though. It might be important to note that in the best case scenario, I won't be pushing more than one button at a time, or turning encoders, or what have you.

My other option is to hook each button up to its own pin on the Mega. Much simpler to code. Much less challenging.

Ideas?



Edit: Third and fourth question. I'm setting the four output Row pins to HIGH, setting the five input Column pins to INPUT_PULLUP, then pulling each row LOW in order and looking for input LOWs. (I had some bad floating issues going the other way.) Is this an acceptable way to do it, or should I work some external pull down resistors into my intermediate connection board and do it my initial way? Also do I need current limiting resistors on my four Row lines, or will it be ok without them?

One Legged Ninja fucked around with this message at 21:13 on Feb 9, 2016

Captain Cool
Oct 23, 2004

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

One Legged Ninja posted:

But now what I'm finding is that I can't think of a fast way to A) turn each button press into the correct serial print without having a big switch case, and B) have each button press only register once until I release the button.

A) is because I'm running it all through for loops, and B) is because I poll each row of switches one at a time, and every time I run through the loop, it counts as a new press.

I could write a switch case to solve A) by cross checking row and column values, then printing out the appropriate value. It just seems like there should be a more elegant way.
What kinds of strings are you sending, and why can't you assemble them based on the row and column values (loop indexes)?

quote:

B) I'm not as sure about. If I create a variable to track whether the button was pressed last time through the loop, I'd need one for each button, or an array of an array of variables.
Sure. Why not? You should be able to create a structure that you can access in the same way as the matrix of buttons. This would also let you do some software debouncing, eg only report a button press if it has been pressed for the last 3 loops.

quote:

I'm also concerned about each of these things taking a long time. The encoders need somewhat good response times to work smoothly. I haven't timed the matrix loop yet, though. It might be important to note that in the best case scenario, I won't be pushing more than one button at a time, or turning encoders, or what have you.
Probably not an issue. At 16mhz, you can execute over two hundred thousand instructions between each video frame. Just use something faster than DigitalRead and make sure you're using a decent serial speed.

quote:

My other option is to hook each button up to its own pin on the Mega. Much simpler to code. Much less challenging.
If you have the pins, this is definitely an option. That's why the Mega exists. The only drawback is that it limits your future expansion.

One Legged Ninja
Sep 19, 2007
Feared by shoe salesmen. Defeated by chest-high walls.
Fun Shoe

Captain Cool posted:

What kinds of strings are you sending, and why can't you assemble them based on the row and column values (loop indexes)?

Sending to the flight sim? Basically just an alphanumeric code like "A01". I can, I just didn't know if there's a better way.

quote:

Sure. Why not? You should be able to create a structure that you can access in the same way as the matrix of buttons. This would also let you do some software debouncing, eg only report a button press if it has been pressed for the last 3 loops.

That's what I was leaning towards, I just wasn't sure it was the right way.

quote:

Just use something faster than DigitalRead and make sure you're using a decent serial speed.

:blush: I haven't learned anything else yet. As I said, I'm teaching myself and figuring out things as I need them. But, like you said, it's plenty speedy no matter what I do, really.

quote:


If you have the pins, this is definitely an option. That's why the Mega exists. The only drawback is that it limits your future expansion.

As far as expansion goes, I'm not too concerned on this project, but I like to learn new stuff when I can, so I'll only use this as a fall back.



Edit: And to sort of answer my own question about adding a current limiting resistor, I hooked up the multimeter and measured the draw with and without one, and it went from 67.5µA with all five buttons pressed in one row with a random resistor, to 350µA without a resistor, so it's a negligible draw for this purpose.

One Legged Ninja fucked around with this message at 22:25 on Feb 9, 2016

Captain Cool
Oct 23, 2004

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

One Legged Ninja posted:

Sending to the flight sim? Basically just an alphanumeric code like "A01". I can, I just didn't know if there's a better way.
Then you don't need a big switch case to put the string together. I think you can do something like this on an Arduino:

buttonstring = "A";
buttonstring += '0' + row;
buttonstring += '0' + col;

If that doesn't make sense, post some code with the switch statement you want to remove.

quote:

:blush: I haven't learned anything else yet.
There's a DigitalReadFast if you don't want to grab the registers directly. And my mistake, the really slow one is DigitalWrite.

General_Failure
Apr 17, 2005
Hi all. The Arduino bits and pieces are still trickling in. I finally have enough to do something useful.

Sadly the 2.4" TFT touchscreen LCD driven by a 7781 seems to be a non starter. I tracked down what should be a decent library for it, got it to compile and still just get a white screen. It's the one with the softbuttons along the bottom of the screen. Has anyone had any success with these? It didn't cost much but it would be nice to be actually able to use it.

I received a bonus with an unrelated order. A micro chopper driver board. It was sent in error but I'm not complaining. The original PIC based throw-together incubator egg tray stepper motor is still chugging along happily. Once I realised that a miniscule offset of the motor causes a large tilt of the trays to one side some careful calibration* was performed and it worked a whole lot better.

e: I got the TFT working. I still need to fix an inversion issue but the rest is done.





*Rushed eyeballing.

General_Failure fucked around with this message at 22:11 on Feb 19, 2016

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


One Legged Ninja posted:

Edit: Third and fourth question. I'm setting the four output Row pins to HIGH, setting the five input Column pins to INPUT_PULLUP, then pulling each row LOW in order and looking for input LOWs. (I had some bad floating issues going the other way.) Is this an acceptable way to do it, or should I work some external pull down resistors into my intermediate connection board and do it my initial way? Also do I need current limiting resistors on my four Row lines, or will it be ok without them?

This is the way I did it.
my main function looks like
code:
loop()
{
	pinMode(SELECT1,OUTPUT);
	digitalWrite(SELECT1,0);
	button1=digitalRead(B1);
	(7 more buttons here)
	pinMode(SELECT1,INPUT);

	pinMode(SELECT2,OUTPUT);
	digitalWrite(SELECT2,0);
	button9=digitalRead(B1);
	(7 more buttons here)
	pinMode(SELECT2,INPUT);
	
	etc.

	if(serial.available())
		{
		serial.read()
		serial.write(button1);
		...
		}
	
}
It works for 24 buttons and 4 axes just fine.
Basically, the thing is updating all the buttons every loop as fast as possible, but it only dumps its data when the other end asks for it. It's possible there are some race conditions or something, and that it's ridiculously inefficient, but w/e.

The software on the other end isn't super intelligent, either; basically just takes in byte values and translates them to useful stuff, then dumps that out to a UDP port for xplane.

goodness
Jan 3, 2012

When the light turns green, you go. When the light turns red, you stop. But what do you do when the light turns blue with orange and lavender spots?
.

One Legged Ninja
Sep 19, 2007
Feared by shoe salesmen. Defeated by chest-high walls.
Fun Shoe

babyeatingpsychopath posted:

This is the way I did it.
my main function looks like

/code

It works for 24 buttons and 4 axes just fine.
Basically, the thing is updating all the buttons every loop as fast as possible, but it only dumps its data when the other end asks for it. It's possible there are some race conditions or something, and that it's ridiculously inefficient, but w/e.

The software on the other end isn't super intelligent, either; basically just takes in byte values and translates them to useful stuff, then dumps that out to a UDP port for xplane.

I got it working on a breadboard shortly after I posted, and then proceeded to solder all my diodes in backwards on the perf board, after explicitly drawing the entire thing out with the correct orientation. :doh: No big deal, I just had to write to five pins and read from four, instead of vice versa. But I haven't implemented it in my main code yet. For the ease of writing the rest of my code, as well as crimping that many more wires, I've just gone 1 to 1 on my Mega. What I'm running into now is so much lag that my encoders are getting less responsive. So I'm going to switch over to either direct port manipulation or the digitalWriteFast library and see how much that helps. Then I'll have to look into making my code more efficient, because I'm sure there's a better way of doing what I'm doing. I haven't timed my loop yet, but I'll try that when I get back today.

huhu
Feb 24, 2006
code:
void screen3(){
    int setupCountdown = 5;
    while(setupCountdown > 0){
        lcdClearLine();
        lcd.setCursor(0,0);
        lcd.print("Creating Folder");
        lcd.setCursor(0,1);
        lcd.print("Starting in " + String(setupCountdown) + "s");
        delay(1000);
        setupCountdown--; 
    }     
}
Is there something I'm missing that changing the content of the paranthases of the while loop to (setupCountdown >= 0) or (setupCountdown >-1) results in an error?

code:
sketch\camera.ino.cpp.o: In function `screen3()':

C:\Documents and Settings\huhu\Desktop\Photostitch\camera/camera.ino:124:(.text._Z7screen3v+0x9c): relocation truncated to fit: R_AVR_7_PCREL against `no symbol'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
How big is your sketch? Usually a linker error like that means your sketch is too big to fit in flash memory. Even though it might be physically smaller than the available flash memory (usually 30-28kb on an Uno.. the bootloader takes a few kilobytes up) the compiler sometimes needs to move variables and code and pad them to be properly aligned for the CPU to access. Sometimes when you're starting to near the limits of available flash memory the compiler can't relocate things properly and gives up with an error like you see. Check out this for more of a description: http://stackoverflow.com/questions/8188849/avr-linker-error-relocation-truncated-to-fit Changing the loop condition is probably changing the code a bit and causing the relocation error (comparing against zero is usually a native jump or branch instruction, but comparing against an arbitrary value like -1 likely requires a different jump and more code). See if you can trim down your sketch and simplify or remove parts that aren't important.

General_Failure
Apr 17, 2005

huhu posted:


Is there something I'm missing that changing the content of the paranthases of the while loop to (setupCountdown >= 0) or (setupCountdown >-1) results in an error?


Skirting on the edge of available memory sounds plausible. I have to ask is there a reason you aren't using a decrementing "for" loop?
And am I tripping balls or did you put the delay in the println in the snippet?

e: nm that last bit. The resolution of my phone and the code combined to make something that looked plausible but wrong.

General_Failure fucked around with this message at 04:01 on Feb 24, 2016

huhu
Feb 24, 2006

mod sassinator posted:

How big is your sketch? Usually a linker error like that means your sketch is too big to fit in flash memory. Even though it might be physically smaller than the available flash memory (usually 30-28kb on an Uno.. the bootloader takes a few kilobytes up) the compiler sometimes needs to move variables and code and pad them to be properly aligned for the CPU to access. Sometimes when you're starting to near the limits of available flash memory the compiler can't relocate things properly and gives up with an error like you see. Check out this for more of a description: http://stackoverflow.com/questions/8188849/avr-linker-error-relocation-truncated-to-fit Changing the loop condition is probably changing the code a bit and causing the relocation error (comparing against zero is usually a native jump or branch instruction, but comparing against an arbitrary value like -1 likely requires a different jump and more code). See if you can trim down your sketch and simplify or remove parts that aren't important.
I was hoping issues like this wouldn't occur on my first attempt at a biggish project. Here is my full code if that answers your question: https://goo.gl/fFd4j4. Issue starts at line 143.

I was hoping to include more components in my project. Mainly just an Arducam but potentially more in the future. How would I go about getting more memory? Is my code horribly written? (Outside typical bad beginner code?)

evil_bunnY
Apr 2, 2003

Get a zero and forget about silly memory limitations.

e: I mean something with an ARM cortex M0

evil_bunnY fucked around with this message at 22:43 on Feb 24, 2016

huhu
Feb 24, 2006

evil_bunnY posted:

Get a zero and forget about silly memory limitations.
code:
    int setupCountdown = 6;
    while(setupCountdown > 0){
        lcd.print("Starting in " + String(setupCountdown-1) + "s");
        delay(1000);
        setupCountdown--; 
    } 
Would I just do it like this then if I wanted setupCountdown to run from 5 to 0?

VelociBacon
Dec 8, 2009

Anyone have an idea where I could find code that would make an LED behave like a flickering candle? Thanks.

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

huhu posted:

I was hoping issues like this wouldn't occur on my first attempt at a biggish project. Here is my full code if that answers your question: https://goo.gl/fFd4j4. Issue starts at line 143.

I was hoping to include more components in my project. Mainly just an Arducam but potentially more in the future. How would I go about getting more memory? Is my code horribly written? (Outside typical bad beginner code?)

What board are you using right now, like a little Trinket or other ATtiny85-based board? Those things are super small on memory and just have a few kilobytes to play with. If you want a small board with more memory check out the Teensy 3.1, Arduino Micro, or Adafruit's feathers (like the 32u4 or M0 feather).

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


VelociBacon posted:

Anyone have an idea where I could find code that would make an LED behave like a flickering candle? Thanks.

A good hack I saw a bit ago just played "happy birthday" to an output, and hooked that up to an LED. It was flickery-enough. If you want something more actually true-to-life with random number generators and stuff then that's also an option.

Sagebrush
Feb 26, 2012

huhu posted:

code:
    int setupCountdown = 6;
    while(setupCountdown > 0){
        lcd.print("Starting in " + String(setupCountdown-1) + "s");
        delay(1000);
        setupCountdown--; 
    } 
Would I just do it like this then if I wanted setupCountdown to run from 5 to 0?


Dunno why you're using setupCountdown-1 instead of just starting at 5 and setting your end condition to >= 0, but yes, that will work.

Also, you can use a for() loop for cleaner code and fewer global variables:

code:
for (int setupCountdown = 5; setupCountdown >= 0; setupCountdown--) {
  lcd.print("Starting in " + String(setupCountdown-1) + "s");
  delay(1000);
}

Sound_man
Aug 25, 2004
Rocking to the 80s

VelociBacon posted:

Anyone have an idea where I could find code that would make an LED behave like a flickering candle? Thanks.

I had a buddy write this article. Full on theatre nerd poo poo. http://www.nxtbook.com/nxtbooks/hickmanbrady/tdt_2015spring/index.php?startid=16#/18

Sagebrush
Feb 26, 2012

babyeatingpsychopath posted:

A good hack I saw a bit ago just played "happy birthday" to an output, and hooked that up to an LED. It was flickery-enough. If you want something more actually true-to-life with random number generators and stuff then that's also an option.

That's not as much a "hack" as it is "literally how those flickering LED candles at the dollar store work." They seem to be recycling the sound chips from musical happy birthday cards etc. and piping the output of that into some RC circuit or the like that drives the LED/

huhu
Feb 24, 2006

mod sassinator posted:

What board are you using right now, like a little Trinket or other ATtiny85-based board? Those things are super small on memory and just have a few kilobytes to play with. If you want a small board with more memory check out the Teensy 3.1, Arduino Micro, or Adafruit's feathers (like the 32u4 or M0 feather).
Arduino UNO

Sagebrush posted:

Dunno why you're using setupCountdown-1 instead of just starting at 5 and setting your end condition to >= 0, but yes, that will work.
Because, this:

huhu posted:

code:
void screen3(){
    int setupCountdown = 5;
    while(setupCountdown > 0){
        lcdClearLine();
        lcd.setCursor(0,0);
        lcd.print("Creating Folder");
        lcd.setCursor(0,1);
        lcd.print("Starting in " + String(setupCountdown) + "s");
        delay(1000);
        setupCountdown--; 
    }     
}
Is there something I'm missing that changing the content of the paranthases of the while loop to (setupCountdown >= 0) or (setupCountdown >-1) results in an error?

code:
sketch\camera.ino.cpp.o: In function `screen3()':

C:\Documents and Settings\huhu\Desktop\Photostitch\camera/camera.ino:124:(.text._Z7screen3v+0x9c): relocation truncated to fit: R_AVR_7_PCREL against `no symbol'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling.

VelociBacon
Dec 8, 2009


Thank you.

huhu
Feb 24, 2006
So I have this arducam running this code and my serial monitor is giving me this:

code:
ArduCAM Start!
170
19
Can't find OV2640 module!
SD Card detected!
Start Capture
The 170 and 19 refer to the two lines of code I added:
code:
  
  Serial.println(vid);
  Serial.println(pid);
The code says vid should be 0x26 and pid should be 0x42. What could be the issue here?

huhu fucked around with this message at 23:10 on Feb 27, 2016

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


huhu posted:

The code says vid should be 0x26 and pid should be 0x42. What could be the issue here?

Well, if the VID and PID don't match what an OV2640 are, then you've got a counterfeit shield, I'd guess. Or there's a configuration error somewhere. You've gotta figure out where those VID and PID numbers come from. 0xAA, 0x13 may be useful information to you if your code is sending someother command to the module than "what's your VID/PID?"

huhu
Feb 24, 2006
:suicide: I figured it out and I'm not going to say what I did wrong.

huhu fucked around with this message at 01:11 on Feb 29, 2016

simplefish
Mar 28, 2011

So long, and thanks for all the fish gallbladdΣrs!


Please do, I'm just getting started with Arduino, I want to avoid doing the same thing

Sagebrush
Feb 26, 2012

Did you put "26" and "42" in as decimal values instead of hex?

huhu
Feb 24, 2006

simplefish posted:

Please do, I'm just getting started with Arduino, I want to avoid doing the same thing

I misread the pinout and assumed that two of the pins weren't required for the camera to run. They were.

Adbot
ADBOT LOVES YOU

simplefish
Mar 28, 2011

So long, and thanks for all the fish gallbladdΣrs!


Sorry, I reckon I'll still do something similar at some point

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