Show Posts
Pages: 1 2 3 [4] 5 6 ... 57
46  Using Arduino / Project Guidance / Re: can somebody help me write arduinoprogram on: April 13, 2013, 11:48:43 am
But have you created an instance of it (via the constructor) in your code (no, you haven't)? You must do that before you can try to use it as an object (the narcoleptic.delay part.) Open the narcoleptic code and look at the function called narcoleptic::narcoleptic. That will tell you how to create an instance of that object in your code. That is called a constructor.

And you need to answer AWOLs question about the virtualwire library. That is the majority of your problem.
47  Using Arduino / Microcontrollers / Re: Bootloader problems... take 2... on: April 13, 2013, 11:43:31 am
Awesome! I'm glad it is working for you.

The one thing that I learned from this is that Nick's sketch is an excellent "recovery" tool given the built in programming, bootloader, and outputting of a clock. This could be used to recover 'bricked' chips. I don't see it currently being passed around as such, but I will certainly do so in the future.

I wonder if Nick would either be willing to create a branch of it specific to recovery (or if he would mind if I did so.) I will have to PM him.

I actually modded my usbtinyasp (adafruit) programmer to output the clock in order to use it for recovery purposes.
48  Using Arduino / Project Guidance / Re: Please evaluate and educate. First post on: April 13, 2013, 11:36:33 am
Quote
There may be cases where we tell someone that a triac is the proper route, and they simply go and plug one in without understanding it, but that is unavaoidable (and hopefully the last time they would try that!) A smart person will instead go and look at how a triac works and all the theory behind it, then either experiment SAFELY or come and ask more questions about parts they don't understand. So, to first assume that they wouldn't go and try to learn about the concept would assume they aren't a smart person.

Everybody is a newbie and a novice at some point. Nobody is born knowing how to connect and control a triac. The best time to learn is when you have something you need to apply it to.

While your points have do have some merit, I just feel you are making too many assumptions about what a given person of unknown knowledge and experience may go off and do with such advice.

 Because AC mains powered devices and circuits have large safety considerations for risks of possible injury, death, and/or major property damage, I have tried to adapt the rather arbitrary stance of "if you have to ask you probably shouldn't be messing with it".

 I try not to sound abusive or condensery about it and many time just won't post a response at all. But I do cringe at time at some of the suggestions or advice given out to what appears to be pretty inexperienced people.

 The internet and it's anonymity allows one to give out advice and recommendations with not much personal accountability of what it might lead to even with the best of intentions. I ask that people at least consider that. 

Lefty

That's because I am not anyone's mother. Their safety is THEIR concern. If they do not have concern for their own safety, absolutely nothing I say is going to save them. I think mentioning it may be dangerous is simply good enough and move on. But we are talking here about an example where no matter what, the user is playing with mains voltage. There is risk, period.

It's not as if I am telling him to plug one end of the mains voltage into pin 2 and the other into pin 4. There isn't enough information given to even harm himself because he will need to go research how to hook it up in the first place.

Honestly, I am not making any assumptions at all. I am giving information. They can do with whatever they want, including ignoring it completely. The only assumptions being made are assuming the person has a lack of common sense, skill or intellect, and honestly.... that is just arrogant.

I would completely disagree that just mentioning that a triac is the right tool for the job is dangerous in any way, shape, or form.

We need to really stop trying to be people's mothers around here. I'm sorry, but that really irritates me. It is condencending by its very nature whether that is intentional or not. The offered solution seems to be holding out information to people simply because we *think* they might be stupid enough to just jam a triac into an outlet because some guy on a forum mentioned the word? Seriously... think about it.

Where do we stop? Should we not talk about scissors because people might cut themselves? Maybe we should tell them that they need to hold the plastic end, not the metal end?
49  Using Arduino / Project Guidance / Re: can somebody help me write arduinoprogram on: April 13, 2013, 11:18:10 am
Actually, most of them are problems with the way you are using the virtualwire library. And the one error regarding narcolpetic is because you are trying to use it as an object, but never declared it.

Honestly, your lack of understanding about how your own code is suppose to work tells me that you didn't actually write this.
50  Using Arduino / General Electronics / Re: Trying to understand a simple flashlight circuit on: April 13, 2013, 11:06:50 am
The diode and 20K resistor I suspect are acting as a very cheap regulator for the microcontroller along with the capacitor to keep things stable when the LED turns on. The PWM is used so they can vary the intensity of the LED.

I would agree. D1 would drop about .5 to .7v, and the rest would drop across the resistor R3. So, if your battery is a 3.2V battery, you would get 2.5V going to the micro.

The missing R1 was probably there to trim the actual voltage, but left out because precision trimmed resistors are much more expensive than normal values, and the micro works within a certain range of voltages anyway, so it didn't need to be exact.

Populating R2, I am not certain about. The only affect I could see would be to split the current?

The missing components (C2 and R6) appear to be a low-pass filter which would convert the PWM to an actual voltage. But that is redundant (in practial purpose) with the mosfet. Perhaps it was there for a lower cost way to do it, but it wasn't reliable enough?

It would appear that all the magic is in the code in that micro.

I realize that your most important question of course is how it senses mode changes between power off... My guess is the brown-out detection. This works by setting a flag when the voltage drops below a certain point. However, the fact that the micro will typically run even at a lower voltage than the brown-out threshhold (and it doesn't cause a reset, it just sets a flag) you can watch that flag to know when to switch modes. The cap likely keeps it running long enough to not completely shut off between button presses.

BOD detection is usually used to signal your controller that power is becoming unstable and it should finish anything sensitive being done (like writing to an EEPROM or flash.) It typically cuts off the write enable so no further writes can be done (but a current write in progress will finish within the EEPROM or flash itself.)

And then there are also other oddball tricks such as powering the micro through a pin other than VCC (yes, this is possible and is done more often than you might think especially in cheap chinese circuits.) So, it could be running the supply voltage through an analog compare pin or a normal analog pin. As the cap discharges, the voltage at that pin would drop and either trip the comparator or the code watching the analog value would trip at some threshhold.

In either case, since the power was only removed temporarily, the code would just keep running and could detect these events. It is likely the brownout detection. The only reason to do it the other way is if there is no brown-out detection on that micro.

BTW, this would also explain the need for the R1 to really fine-tune that BOD threshhold vs. minimum supply voltage.
51  Using Arduino / Project Guidance / Re: can somebody help me write arduinoprogram on: April 13, 2013, 10:26:00 am
And showing that you have not bothered to read the sticky at the top of this forum exmplaining how to use code tags, really shows your actual unwillingness to learn.

I'm sorry, Santz, but I seriously doubt that you are going to get any help here with your approach to this. Though I do respect your honesty in telling us it is a university project. That alone would not have precluded my help. But as far as I can tell, the real problem here is that you are too impatient to do the 'work' involved in learning something and want others to solve your problems. Perhaps you should consider management as your career choice, instead?
52  Using Arduino / Microcontrollers / Re: Connect webcam to Arduino on: April 13, 2013, 10:21:05 am
The bottom line is that you are not going to get the Arduino to read your webcam. And if you are streaming it to the PC per your original question, how does that make it anymore portable than simply connecting to the PC? It still requires the PC.

For one, even if the Arduino could handle the image, you would need a USB host and all the stack code and overhead to go with it to connect to the camera. Think about the resources involved in that part, and then you want to process an image on top of that?

Leaving the USB connectivity part aside, I suppose you could ignore a ton of data from the camera by breaking into blocks and just focus on average color value to use the camera as a color sensor. But even with that, you are going to get stuck on the pesky USB connection part.

I think you need to re-think this. A color sensor probably is the best choice. Or using a raspberry pi as suggested.
53  Using Arduino / Microcontrollers / Re: ATMega1284P Issues on: April 13, 2013, 09:59:20 am
Actually, using a 16.934Mhz oscillator makes for a more accurate buadrate division which means less errors:

Quote
Freq (MHz)       Buadrate    Notes
16.9344  115200         Used in CD-DA systems and CD-ROM drives; allows integer division to 44.1 kHz (384×44.1 kHz), 22.05 kHz, and 11.025 kHz. Also allows integer division to common UART baud rates up to 115200. Frequencies also used are 11.2896 MHz, 22.5972 MHz, 33.8688 MHz and 45.1584 MHz.

http://en.wikipedia.org/wiki/Crystal_oscillator_frequencies

(error rate of 3.7% at 16MHz vs. 2.0% at 16.934Mhz so still not 'perfect' but actually better than 16Mhz exactly.)
54  Using Arduino / Microcontrollers / Re: ATMega1284P Issues on: April 13, 2013, 09:48:10 am
Quote
The resonator being at 16.9Mhz is probably not a big deal. It may screw up your timing a bit, but it shouldn't be causing your issues.

I would not make that assumption. I would first suggest changing to a 16Mhz resonator and retest.

Lefty

He already tried that (tapping off the Uno board)...

it didn't work.

I think my assumption is perfectly safe.
55  Using Arduino / Project Guidance / Re: Please evaluate and educate. First post on: April 13, 2013, 09:41:53 am
The software side looks non-trivial but definitely feasible. It is the hardware and power side that is uncertain. It's certainly possible to regulate mains voltage AC directly and plenty of resources showing how to achieve this using zero crossing and a triac, but it's not IMO a job for a novice.

I agree with you completely Peter, but when I see advice like this, I hear "Don't cook, leave it up to the chefs!" People learn by doing. Introducing someone to the right concepts points them in the right directions to begin learning. Usually THAT is the step that people are stuck on (just like I was with the PID issue you helped me with.)

I am not saying that you are wrong, I just keep seeing that type of advice here and it is troubling and could easily be perceived as insulting (it would be to me.) I don't consider myself stupid, a newbie, or even a novice simply because I ask a question. Sometimes I just need someone to point in the direction that I need to look to speed up the process of learning, to introduce me to a new concept I wasn't aware of, or to break my tunnel vision. But I know that I will need to go and learn about whatever is new on my own. Just need a nudge sometimes or a fresh perspective.

Personally, I find it much more respectful to approach helping people that way.

There may be cases where we tell someone that a triac is the proper route, and they simply go and plug one in without understanding it, but that is unavaoidable (and hopefully the last time they would try that!) A smart person will instead go and look at how a triac works and all the theory behind it, then either experiment SAFELY or come and ask more questions about parts they don't understand. So, to first assume that they wouldn't go and try to learn about the concept would assume they aren't a smart person.

Everybody is a newbie and a novice at some point. Nobody is born knowing how to connect and control a triac. The best time to learn is when you have something you need to apply it to.

To close off certain information because we assume that someone isn't going to understand it feels a bit arrogant to me. We are here to learn, to teach, and to help, right?

You are always helpful, so please don't think I am assuming that you intend it that way at all. Just would love for people to take a moment and think about how this would come across to them if someone were to say it to them.
56  Using Arduino / Programming Questions / Re: looking for help to translate a sketch so that non-programmers understand it on: April 13, 2013, 09:16:35 am
First of all thanks for all the advices.

Code:
int inCount = 0;
if(inCount < 31 && ch != '\r' && ch != '\n') {
inBuffer[inCount] = ch;
inCount++;
inBuffer[inCount] = 0;
This part is declaring an index into an array, checking that the index is still in bounds, using it to store a character in the array, incrementing it, and then using it to store a NULL in the array.

Thank you.. if you should explain this for a newbie in programming how will you do that? maybe by using an metaphor

Exactly how AWOL described it:

In other words, it is building a C string, character by character.

If you are trying to teach a non-programmer how to program, the best way is to break things down in terms of function. And then explain it to them in terms they understand and give examples of ordinary things.

For example, programming is pretty much like a recipe. There is the setup and preparation, and then the actual steps. Ingredients would be like variables, pin definitions, constants, etc...

Interrupts are like the phone ringing or an alarm going off, etc...

Get them to think about how they go through the day. They have a series of sequential steps which are varied by inputs. Tests (If, Switch, While) are like checking the temperature of water before adding the pasta.

You get the idea...
57  Using Arduino / Programming Questions / Re: looking for help to translate a sketch so that non-programmers understand it on: April 13, 2013, 09:07:56 am
Is the intention to teach someone that doesn't know how to program how to program by using an example? Or is it to simply explain to someone what your code does?

I fail to understand why a non-programmer would want or need to look at code in the first place.

Consider this:
Input-Processing-Output

The average person only needs to understand input and output, and how they relate to each other (what input generates what output.) They don't need (nor normally care) what the processing part does. So if that is your intended audience, present it to them only in that way.
58  Using Arduino / Project Guidance / Re: Please evaluate and educate. First post on: April 13, 2013, 08:47:25 am
And to answer one of your original questions... if you use a triac instead of a FET, you can simply control the AC voltage directly without the need for the transformer. But you do need to keep in mind switching at the zero crossing point, which means you need a detector circuit for that.

Likely your vibrator would work with a pulsed DC voltage instead of AC. In which case, you could simply use a FET and not have to worry about the zero-crossing point.
59  Using Arduino / Project Guidance / Re: Please evaluate and educate. First post on: April 13, 2013, 08:38:26 am
"The voltage and frequency I suspect is not critical, at present 160v is flat out."

Yes. But it isn't already doing what you want. Frequency will control the speed of the vibration, voltage/current will control the strength of the vibration. Increasing the strength of the vibration will only make your nuts bounce higher on the belt. Controlling the speed (frequency) of the vibration will increase the energy, which will make the nuts move along faster.

Look at it this way... imagine the waveform of your vibration and your nuts riding on that waveform because that is pretty much what is happening here. The crests jump the nuts up off the belt. A higher amplitude crest will only make them jump higher. Now, in this configuration, the nuts are simply jumping up and down vertically and there is no forward or backward motion.

Typically (there are various types of vibrating conveyors, not sure which type you are using) the surafce has a slight incline, so that when the nuts jump in the air, they fall forward. In this case, the vibration is actually just reducing friction, really (by sending the nuts up off the surface.) Vibrating them faster would keep them in the air more often, so less friction means they fall faster down the surface. I suppose that increasing the amplitude would keep them in the air longer which would also acheive this purpose to some degree. But you risk jumping them high enough to either knock them over the edges or start breaking them apart. You also increase wear and tear on the machine this way.

So three variables will control the speed:
The steepness of the incline, the frequency of the vibration, and the amplitude. Out of those options, the amplitude would seem to be the one with the most drawbacks. Ideally, if you could get the frequency high enough, you would essentially create an air pocket beneath the nuts and they would essentially just float above the surface (like a table hockey game.) Also increasing the frequency high enough would reduce the noise. That would require ultrasonic frequencies. Of course there are mechanical limitations to how high a frequency you can go.
60  Using Arduino / Project Guidance / Re: Its in the code... on: April 13, 2013, 07:04:56 am
Code:
if( analogRead(buttonPin) ) {
   const int L1 = 1;
Why keep rescoping a constant?

Yep. Not sure what the OP is trying to do there. L1 is the pin number for one of the relays. Pin 1? The serial pin? I also notice that he/she is using pins 0 and 1 for the relays, but intializing the serial port with Serial.begin(9600);

This code is all kinds of screwed up. We have two groups here: MODEn and Ln. Both groups are configured as output. But at the end of the loop, the OP is trying ti digitalRead the Mode pins (2, 7, smiley-cool.

Finall, the reason your relays are always high is that you have probably connected your buttonpin with a pullup which is the proper way to connect a switch. But you are testing for it to be HIGH, which it always will be EXCEPT when you press it. So, your code is starting with state=1, then going through the states and ending up back at state=1. And since it always sees your pin as HIGH, the code just keep running forever regardless of your button presses.

I would recommend sitting down and writing up some psuedo-code for what you want to do and rewrite this. Use case statements instead of IF statements. Properly think out your pin assignments and whether they are inputs or outputs. Rethink that "debounce" code (which isn't actually doing anything here other than delaying... for deounce, you check the pin again after the delay and only register the HIGH or LOW if it is the same state after the delay.)
Pages: 1 2 3 [4] 5 6 ... 57