HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Jul 03, 2010, 03:34 PM
Registered User
United States, NV, Carson City
Joined Apr 2008
17 Posts
sj: The same board as Ian, the Nano. My programing skills are nonexistent, therefor, I think it would be best if I went with a known quantity.
I am also in the process of building the kapteinkuk board @ http://www.rcgroups.com/forums/showthread.php?t=1143569 .

You know, there are some really smart people hanging out around here.

Fun vid. If you want to see some amazing stuff, jump over to http://timescapes.org/phpBB3/index.php

Later...
Yorbid is offline Find More Posts by Yorbid
Reply With Quote
Sign up now
to remove ads between posts
Old Jul 04, 2010, 02:20 PM
Registered User
United States, NV, Carson City
Joined Apr 2008
17 Posts
Ian, please forgive for "looking a gift-horse in the mouth," but I get code errors when I try to load the .pde files to the Nano. I am using the programing software at http://arduino.cc/en/Main/Software . SJ has no problem loading, think I'm doing something wrong...well, I must be. I am using the USB port, not the ISP, if that makes a difference.

Thanks, Yorbid
Yorbid is offline Find More Posts by Yorbid
Reply With Quote
Old Jul 04, 2010, 04:41 PM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
Quote:
Originally Posted by Yorbid View Post
Ian, please forgive for "looking a gift-horse in the mouth," but I get code errors when I try to load the .pde files to the Nano. I am using the programing software at http://arduino.cc/en/Main/Software . SJ has no problem loading, think I'm doing something wrong...well, I must be. I am using the USB port, not the ISP, if that makes a difference.

Thanks, Yorbid
Hi,

What code errors are you getting?

In the meantime, some info:-
All I have ever used is the USB port.
Have you selected the correct board using the Arduino software, also selected the correct com port.

See TOOLS, BOARD.........
Also, TOOLS, SERIAL PORT.........

If the Serial Port option on the menu is greyed out then your PC isn't recognizing the Arduino board, i.e. driver problems.

Just to recap:

Create a folder called RCJoystick_IanJ_V2 and put the 2off .pde files in there.
RCJoystick_IanJ_V2.pde
LCD0821.pde

Open the first .pde with the Arduino software and hit upload.

Ian.
IanJ is offline Find More Posts by IanJ
Last edited by IanJ; Jul 04, 2010 at 05:08 PM.
Reply With Quote
Old Jul 05, 2010, 04:31 PM
Registered User
United States, NV, Carson City
Joined Apr 2008
17 Posts
Hi, Ian

I have been able to upload the blinking LED example sketch without problems. That part of the system seems to work OK.

When I upload the RCJoystick_IanJ_V2 file doing a copy and paste from your site I get this error:
Name: RCJoystick_IanJ_V2.jpg
Views: 250
Size: 84.5 KB
Description:
If I use the Copy icon at the top right of the code box on your site I get this error:
Name: RCJoystick_IanJ_V2  2.jpg
Views: 160
Size: 75.3 KB
Description:

Don't ya hate it when you have something that works just fine and then let someone use it and you end up supporting it because the user don't know squat about nothin.

Anyway, I'll start reading about C++ and try to understand the syntax and what might be causing the problem. Again, if you and sj are not having errors it would appear the problem is at my end. Most strange.

Thanks again Ian.
Yorbid is offline Find More Posts by Yorbid
Reply With Quote
Old Jul 05, 2010, 05:16 PM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
You got the first error because you copied the line numbers along with the code.
The 2nd method, i.e. using the copy button at top right is the correct way.

Did you do the same with the 2nd PDE and name it LCD0821.pde and drop it in the same folder. The 2nd error you are getting is definitely because the main code isn't able to find the additional PDE.
The code listing on my webpage is actually 2off separate PDE's.....scroll down and you'll see the 2nd one.

Here's a screenshot from my PC......when you open the main PDE the 2nd one is automatically loaded. Looking at your screenshot it's only showing the main PDE.

You are very close.......keep trying, and no need for C++ books......

Ian.






PS. The applet folder will be created the first time you upload (compile) the Arduino code...so don't worry about that.
IanJ is offline Find More Posts by IanJ
Last edited by IanJ; Jul 05, 2010 at 05:24 PM.
Reply With Quote
Old Jul 05, 2010, 09:38 PM
Registered User
United States, NV, Carson City
Joined Apr 2008
17 Posts
Too Cool!

It appears the deed has been done. At least a lot of flashing lights, no errors and the blinkie program that I loaded yesterday went away.

Now I will continue to wait for the rickshaw with my order before I can try it out.

I think I am going to try a handful of these things http://www.melexis.com/Sensor_ICs_Ha...90333_648.aspx
or maybe make my own. I wish I could remember the site these came from. They were making full-sized flight sim parts and had some great ideas and innovative ways to make parts work.

Thanks again, Ian
Yorbid is offline Find More Posts by Yorbid
Reply With Quote
Old Jul 06, 2010, 01:40 AM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
One important piece of info:-

If you are using the same LCD as me, then do not upload code to the Arduino with the LCD connected.

The reason being is that the USB connection to the PC shares the same data lines as the RS232 connection to the LCD. So, when you upload code to the Arduino it's actually being sent to the LCD at the same time. And since the LCD is programmable then what can happen is that the LCD interprets the data incorrectly and can upset the settings within the LCD.

Net result is a bricked LCD. You'll know you've bricked it when you power up and the LCD remains blank instead of displaying battery voltage etc.

There is software codes for the LCD to 'reset' it to factory defaults, however, this doesn't work fully and the LCD still remains bricked. The only way to fix is to send the LCD back to the manufacturer.

To be fair, I uploaded to my Arduino 50odd times before I noticed a problem, but I guess it's just a bit of pot luck....might never happen, could happen on your first go!

You can of course use a different type of LCD, however, you'd have to re-write my code accordingly. However, I chose a serial LCD for the low overheads on the Arduino cpu resources.

Ian.
IanJ is offline Find More Posts by IanJ
Reply With Quote
Old Jul 06, 2010, 05:30 AM
five by five
sonicj's Avatar
Panama City Bch, FL
Joined Jan 2009
2,074 Posts
ian, have you considered redefining the lcd to a unused pin? you could upload new sketches without having to disconnect the lcd every time.

btw, i killed my lcd yesterday in the same manner. think i'll have to build/buy a iscp programmer to get it back to normal.
-sj
sonicj is offline Find More Posts by sonicj
Reply With Quote
Old Jul 06, 2010, 06:04 AM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
Quote:
Originally Posted by sonicj View Post
ian, have you considered redefining the lcd to a unused pin? you could upload new sketches without having to disconnect the lcd every time.

btw, i killed my lcd yesterday in the same manner. think i'll have to build/buy a iscp programmer to get it back to normal.
-sj
Actually, I found that the LCD isn't necessarily killed completely. You may find it's blank or only partially displays the data you send it....and the remedy to fix is to send the various codes to change it's config. Keep changing and modifying the codes such as brightness, autolinewrap etc etc back and forth and suddenly it will come back into life.
I got it back three times from the dead, it wasn't till the 4th time I bricked it for good then realized why. SHould have noticed earlier the LCD flash up loads of rubbish each time I uploaded new Arduino code!

Anyways, I bought a new one and at the same time also contacted the manufacturer to tell them they should employ a full factory reset function/pin or lock. I also asked them if they could send me the LCD firmware so I could flash it but they wouldn't/couldn't.

The LCD is on the Arduino serial port, however, the NANO only has 1 serial port so unless a special driver is used in order to use a normal digital pin then I think we're stuffed into using the shared port. I'm not an Arduno expert, but that's how I see it.

Ian.
IanJ is offline Find More Posts by IanJ
Reply With Quote
Old Jul 06, 2010, 12:32 PM
Registered User
United States, NV, Carson City
Joined Apr 2008
17 Posts
Ian,

Is the LCD necessary for operation?

Yorbid
Yorbid is offline Find More Posts by Yorbid
Reply With Quote
Old Jul 06, 2010, 01:07 PM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
Quote:
Originally Posted by Yorbid View Post
Ian,

Is the LCD necessary for operation?

Yorbid
Strictly speaking, no it's not................but:-

You won't know your battery voltage till the low voltage buzzer/beeper sounds.

You won't know what rates you've set (lo, mid, high). Each press of the rates button rotates the rates around lo/mid/hi. The only thing you will know is that on power up the code defaults to mid rates.

I remember when I bricked my LCD I did continue to fly my quad with the joystick without problem.

Ian.
IanJ is offline Find More Posts by IanJ
Reply With Quote
Old Jul 08, 2010, 04:54 AM
five by five
sonicj's Avatar
Panama City Bch, FL
Joined Jan 2009
2,074 Posts
friggin' awesome!

i moved my joystick from a solderless breadboard to a perfboard setup and installed the rx into a model. very, very cool!

as always, i thought of a better way to configure the board midway through, but i went ahead and finished it the way i started since i don't have all the stuff i need to do it differently. i opted for leaving the arduino & tx outside of the joystick case for ease of access. in the next revision, each pot will have its own 3pin connection, just like servos connected to a rx. this way i can swap a single set controls (ie: pedals) or move to a steering wheel or even a heli chair with ease.

still trying to figure out the x1 y1 servo reverse & compensation portion of your code ian... i need to reverse the throttle & elev and match the throttle range to the pot travel. any thoughts?

cheers!
-sj
sonicj is offline Find More Posts by sonicj
Reply With Quote
Old Jul 08, 2010, 06:04 AM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
Quote:
Originally Posted by sonicj View Post
friggin' awesome!

i moved my joystick from a solderless breadboard to a perfboard setup and installed the rx into a model. very, very cool!

as always, i thought of a better way to configure the board midway through, but i went ahead and finished it the way i started since i don't have all the stuff i need to do it differently. i opted for leaving the arduino & tx outside of the joystick case for ease of access. in the next revision, each pot will have its own 3pin connection, just like servos connected to a rx. this way i can swap a single set controls (ie: pedals) or move to a steering wheel or even a heli chair with ease.

still trying to figure out the x1 y1 servo reverse & compensation portion of your code ian... i need to reverse the throttle & elev and match the throttle range to the pot travel. any thoughts?

cheers!
-sj

Reversing direction can either be done in the software, or on the pot itself, however, depending on the joystick you might not be able to swap the wires at the pot if say it's a hall effect type pot. If it's just a normal pot then swap the 2 outside wires.

So, here's the software method:-

Original:-
AI_Eleva = map(AI_Raw_Eleva, 0, 1023, 0, 1023) + 0; // Elevator

Reversed:-
AI_Eleva = map(AI_Raw_Eleva, 0, 1023, 1023, 0) + 0; // Elevator

Next, lets say the pot output isn't 0 - 5vdc, but you are getting 1 - 4vdc.
So clearly you won't get the desired output range from the code after y=mx+c in order to drive the PPM signal.
So, what you need to do is frig the numbers a bit. As follows:-

By default,
AI_Raw_Eleva, 0, 1023, 1023, 0
Means that the raw signal (AI_Raw_Eleva) from the analogue input over it's 0-5vdc input will give a value in the variable from 0 to 1023. This maps to 0 to 1023 in the output variable from the calc (AI_Eleva), or to be precise 1023 to 0 since in the above case it's reversed/inverted.

This new value is then passed to the dual rate routine, basically multiplied by a factor depending on what rates you want. On top of that the value is adjusted to suite the PPM output value requirements, i.e. adding the PPM min value.

So, if you want to set up your throttle so that you get a nice 700uS to 1700uS for the full range of you pot, (and nicely centred if its AEL or ELE) then the way I did it was to slightly frig the values at the mapping stage. i.e.

AI_Throt = map(AI_Raw_Throt, 0, 1023, -25, 1150) - 0;

You can see that for 0-1023 coming in, I mapped it to -25 to 1150. My pot was not physically giving 0-5vdc, it was giving something like 0.5 to 4.0vdc.
(Remember that 0-1023 to 0-1023 is a gain of 1).
Of course, -25 or 1150 will never be reached but thats not important, the important thing is that I gave the mapping a gain of more than 1 so that if 40 to 920 came in from the physical pot then it will map to approx. 0-1023 via the slight increase in gain.
Also remember that for the AEL, RUD & ELE you can also play with the offset, i.e. the +c part of y=mx+c...........i.e. equivalent of stick trimming on your traditional Tx. In my code my pots were all pretty good vie the default of -0 but you can play with positive or negative numbers there to offset it, but bear in mind the offset will affect your endpoints.

Yes the above is a bit of a hack, and if I had the time I'd employ an intelligent calibration routine whereby you put the whole Tx in calibration mode and wiggle the stick to all it's extends and it would learn the voltages coming from the pots and map them automatically and perfectly to 0 - 1023.
I coould probably do it, but I ain't a good programmer so it would take me a wee while to hack it in.....

Hope that helps?

Ian.
IanJ is offline Find More Posts by IanJ
Reply With Quote
Old Jul 08, 2010, 08:13 AM
five by five
sonicj's Avatar
Panama City Bch, FL
Joined Jan 2009
2,074 Posts
cool! makes sense now

it took about 2sec to swap the direction in software!

travels appear perfect for aile & elev! (no rudder yet) i played with the numbers for the throttle but they didn't behave as i would have thought... widening the values like so: AI_Throt = map(AI_Raw_Throt, 0, 1023, 1073, -50) -0; // Throttle didn't seem to give the throttle pot additional usable range, even after recalibrating the esc. i'll put my meter on it and see what is going on voltage wise. i did notice that it has significantly larger range of motion; something like 160.

auto calibration would be sweet! if i knew how to do it i would! i'll figure out something to add to the project once i get a handle on this coding mumbo jumbo!
-sj
sonicj is offline Find More Posts by sonicj
Reply With Quote
Old Jul 08, 2010, 12:16 PM
Registered User
Aberdeen, Scotland, UK
Joined Dec 2007
607 Posts
Quote:
Originally Posted by sonicj View Post
cool! makes sense now

it took about 2sec to swap the direction in software!

travels appear perfect for aile & elev! (no rudder yet) i played with the numbers for the throttle but they didn't behave as i would have thought... widening the values like so: AI_Throt = map(AI_Raw_Throt, 0, 1023, 1073, -50) -0; // Throttle didn't seem to give the throttle pot additional usable range, even after recalibrating the esc. i'll put my meter on it and see what is going on voltage wise. i did notice that it has significantly larger range of motion; something like 160.

auto calibration would be sweet! if i knew how to do it i would! i'll figure out something to add to the project once i get a handle on this coding mumbo jumbo!
-sj
If you meter the voltages then you could actually calculate what the figures for the software should be before typing them in. A little bit of maths, or even good old fashioned graph paper.

But like I said, the hardest part is getting the stick centred when you start tampering with y=mx+c

Ian.
IanJ is offline Find More Posts by IanJ
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Looking for cheap RC radio TX/RX sets 1145climber Electric Power Cars 3 Apr 08, 2010 05:24 AM
Build Log Re-inventing /modding Thunder tiger's P-51D Mustang kusunokimasahige Electric Warbirds 12 Mar 22, 2010 12:57 PM
Discussion Re-inventing the wheel philgib Blimps 5 May 25, 2006 06:42 PM