|
1456
|
Using Arduino / Programming Questions / Re: Passing class-member function to another class
|
on: March 04, 2012, 04:45:06 am
|
Hi, Quoting from the link provided by the previous poster - [33.2] How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?
Don't.
As I mentioned in my original response, an object orientated approach is valid, but in a micro controller you are much closer to the hardware and sometimes it good to acknowledge this and enjoy the differences. If you want to continue with the OO approach, I would suggest that you revisit your objects so that they are less tightly coupled - i.e. should the alarms be inside the heat tape object - could you achieve what you want more easily if they were outside ? Duane B.
|
|
|
|
|
1457
|
Using Arduino / Programming Questions / Re: Passing class-member function to another class
|
on: March 04, 2012, 02:30:18 am
|
Hi, From very distant memory, you can only pass a static function as a callback function, static functions are associated with the class, not any individual instance (object) of the class so you will not have access to your object variables, only status variables. As all your doing is turning pins on and off, I might suggest that you take off your perfectly valid but may be out of context 'object orientated' hat and put on your microcontroller 'how can i get this done in 2k memory' hat and have another look at what your trying to do. Just a suggestion and there is nothing wrong with trying to do it in objects other than in this case your are inventing problems for yourself - i.e. how do I use half a dozen layers of complexity to change a pin. Duane B rcarduino.blogspot.com
|
|
|
|
|
1458
|
Using Arduino / Sensors / Re: Suggestions on IR communication
|
on: March 04, 2012, 01:01:34 am
|
Hi, No need for headers, the problem you have is a very simple one that has been solved for over 40 years - how to get multiple proportional channels into a single transmission channel. Read my last post again (and again if need be) and pay particular attention to the 'heres how' part. I can put it another way which is - each channel has a fixed position within a fixed frame. If we dont see any pulses for a period we know the frame has ended and the next pulse is the first channel of a new frame, the pulse after that, the second channel. The order of the pulse within the frame gives us the channel number, the width of the pulse gives us the proportional signal for that channel. something like this 1200000012000000120000001200000012000000 Duane B rcarduino.blogspot.com
|
|
|
|
|
1459
|
Using Arduino / Sensors / Re: Poor performance of IR LED
|
on: March 04, 2012, 12:55:29 am
|
Hi, Are you using the setup inside or outside, is there a lot of natural light around, maybe coming in through a window, if so try a shade around the camera sensor - without a shade my lap timer does not work at all, with a small matt black cardboard tube around the sensor it works flawlessly. Also try driving the LED with more current, I am driving mine with 100ma - obviously not directly from an Arduino PIN. You mention that you are sending a signal, I assume that this is a 38Khz coded signal of some sort in which case the LED is off a lot of the time and can be driven harder. To get a wider angle from a single LED, reflect it off something, try a quick experiment like pointing the LED up and reflecting if off your hand towards the camera, you will get a much wider viewing angle - a sheet of white paper or aluminium foil in a small housing for your transmitter will do the same but much more efficiently. I am using IR Emitters and Detectors for an RC Car lap timing project here - http://rcarduino.blogspot.com/2012/03/punk-consoles-and-ir-transmitters-555.html EDIT: If you off load generating the 38Khz IR signal to a 555 timer, you can drive the LED harder and use a potentiometer to tune the frequency which will both help with range. Duane B rcarduino.blogspot.com
|
|
|
|
|
1460
|
Using Arduino / Sensors / Re: Suggestions on IR communication
|
on: March 03, 2012, 01:04:50 pm
|
Hi, To tell which channel a pulse is for I would suggest an approach similar to radio based RC Systems. They use a fixed frame which contains all of the channels as consecutive pulse widths. If you use the servo library you can cheat a bit and get it to do most of the work for you. The servo library automatically generates pulses using a 20ms frame, the pulses for each channel within the frame are between 1 and 2ms long.  See here for background - http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.htmlThe problem is that the Arduino Servo library doesn't quite do this in exactly the same way as an RC transmitter, but by using one dummy servo we can fake it so that its close to an RC Transmitter signal and will allow us to get two channels in and out of the signal. Heres how - 1) Create a throttle servo and attach it to a throttle pin 2) Create a dummy servo and attach it to an unused pin 3) Create a steering servo and attach it to a steering pin We use the dummy servo to create a 1.5 ms space in the signal between the throttle and steering pulses. Note: 1.5ms is the default pulse width we could change it. In our receiver code we can work on the basis that - 1) If we haven't seen a pulse for over 10ms the pulse we are looking at now is the throttle 2) If we saw a pulse less than 2ms ago, that was the throttle and the current pulse is the steering. The dummy servo is not used, but because of the way the Arduino Servo Library is written, we need this to create a gap between the end of the throttle and the start of the steering pulses within our single IR Channel. You will need a small circuit to allow the throttle and the steering pins to activate your IR Emitter, or you can cheat and do a quick test with two IR Emitters if you have them - just for testing ;-) Some IR Detectors have rules about the types and sequences of pulses that they will process, if that is the case with yours I am sure we can work around it. Duane B rcarduino.blogspot.com
|
|
|
|
|
1462
|
Using Arduino / Programming Questions / Re: Precompiler directives - is there a case statement?
|
on: March 03, 2012, 05:57:27 am
|
Hi, There are just if, elif, else and endif. If you look through the source code for the Arduino libraries you will see how these are used for a similar purpose to yours - they are sometimes used in combination to deal with the different Arduino processors (ATMega8,168,328 etc) and different clock speeds. If you look in Servo.cpp you will see what appear to be nested directives - something I didn't know was possible until seeing it now ! Duane B rcarduino.blogspot.com
|
|
|
|
|
1464
|
Using Arduino / General Electronics / Re: Dont Waste Your Time
|
on: March 02, 2012, 01:59:39 pm
|
Hi, I will get the wife to pick some up when she is in Europe next month, I am also desperate for heat shrink small enough for component wires. In Dubai you can buy the parts to start anything whatever your interests are, you just can't buy the parts you need to finish it. There is a metaphore for The city as a whole in there somewhere. Duane B rcarduino.blogspot.com
|
|
|
|
|
1465
|
Using Arduino / General Electronics / Re: Dont Waste Your Time
|
on: March 02, 2012, 12:57:43 pm
|
Hi, While there is certainly a lot of electolyte rich sweat in the Dubai heat, these strip boards are just plain bad quality. On some the copper strips visibly wander and on some the pin spacing changes, the worst do both ! I try to pick the best, but as there never seems to be any new stock my selection is getting worse and worse :-( Duane B. rcarduino.blogspot.com
|
|
|
|
|
1466
|
Using Arduino / Programming Questions / Re: Sending data directly to Excel
|
on: March 02, 2012, 12:52:22 pm
|
Hi, While it looks like people have suggested successful approaches for getting data into excel, have you looked at using processing ? Its a visuallisation orientated programming language that talks very easily with Arduino. Have a look here - http://processing.org/ You could create great graphics and animations fairly easily, have a look at some of the examples, I especially like the transforms for 2d and 3D work - not that I have done any, it just looks like a neat approach. Duane B rcarduino.blogspot.com
|
|
|
|
|
1467
|
Using Arduino / Project Guidance / Re: Radio Shack IR emitter/detector pair test
|
on: March 02, 2012, 12:45:08 pm
|
Hi, Its good that you have something up and running, for your next project you can move anything that you want to do once only such as your print your intro into the setup function, its there to do one time setup and anything else you want to happen once before loop starts. I often do something similar to you and have my sketches send the sketch name and version to serial, put this into setup and you can take the if statement and extra variables out of loop, you can move setting the LED High into setup as well. I don't know how interested you are in the programming side of things, it looks as if you might be interested because you are doing some very good things, I like that you have long readable variable names minVal, maxVal, oldVal instead of n,m,x,y etc. Its also really good that you are using define statements for your fixed values. If you had a look through loop you could find some lines of code that could be moved, for instance if its not a new value its not a new min or max value either so you could move these two tests inside the first test for a new value. Its not essential, but it makes code easier to manage as you get onto bigger projects. Duane B rcarduino.blogspot.com
|
|
|
|
|
1469
|
Using Arduino / Project Guidance / Re: Help buying Arduino Board
|
on: March 02, 2012, 12:05:39 pm
|
Hi, This is really good advice - 'get an Uno and save your money to buy sensors and other hardware' - the Uno is cool but on its own there really isn't very much to do, but follow wildbills advice and get a load of inputs and outputs and who knows what you will end up building. Duane B rcarduino.blogspot.com
|
|
|
|
|
1470
|
Using Arduino / Sensors / Re: Suggestions on IR communication
|
on: March 02, 2012, 08:21:01 am
|
Hi, The 38 at the end of the part number tells you the frequency that the receiver expects, so in this case its 38Khz. You can use code to generate the 38Khz, but the 555 timer is such a fundamental chip to so many projects that you might as well figure out how to use one, it will also allow you to drive your IR Transmitter with much more power than an Arduino PIN, this will increase your range and reliability. Something quick to try is to build a 38Khz circuit with the 555 Timer, then use your Arduino to drive a servo signal which will enable/disable the 555 timer using the reset pin. On the receiver side, you 'might' be able to drive a servo with just a 5v power supply and the IR Receiver. If you want to get away from the requirement for a 38Khz signal, you can try an infra red detector instead of a receiver, but its so easy to generate the 38Khz signal with a timer (Arduino or 555) and it makes for a much more reliable system. Here is a quick update on one of my own projects where I am using an infrared detector the same as yours to detect my RC Car lapping. The RC Car has a simple 555 timer circuit (no arduino) outputting a 1 millisecond pulse of 38Khz IR signal. http://rcarduino.blogspot.com/2012/03/punk-consoles-and-ir-transmitters-555.html One limitation of this is that if I want to use the system in bright sunlight I need to enclose the detector in a shade, this is no problem for me as I need the detection zone to be very tight anyway but If you plan on using your control system outside, IR might not be practical for you. If you decide not to go this way, build a 555 punk console, I have been dying to but haven't found the time. If do you want to take the IR route, I would suggest that you do so in stages, and as a first stage I would suggest that you build the battery driven detector circuit from the Lady Ada link and build a 555 IR circuit. If you can activate the LED in the detector circuit with your 555 circuit, the next step would be to connect the 555 to the Arduino, let us know when you are ready to do that, you will need to add some decoupling capacitors first but we can get into that when we need to. After the decoupling capacitors it should all be simple enough. EDIT: I have a nagging idea that its would possible to build the entire transmitter and receiver from a few timers, I have never tried it, but logically I can see how it could work. Duane B rcarduino.blogspot.com
|
|
|
|
|