Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Arduino and Bascom
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sun Jan 31, 2010 9:34 pm    Post subject: Arduino and Bascom Reply with quote

Here some information to get the Arduino Duemilanove with an Atmega328p running with Bascom-AVR. This is the board with an USB connector and a bootloader. Have put my USB serial port on COM3

Choose as programmer in Bascom:

Code:
Bascom: external programmer

Program: C:\arduino-0018\arduino-0018\hardware\tools\avr\bin\avrdude.exe

Parameters: -v -F -Cc:\avrdude.conf -p m328p -P com3 -c STK500v1 -b 57600 -U flash:w:{FILE}:a
 


==

place the avr-dude configuration file "avrdude.conf" in the root (or change the path in the parameters).


==


The fusebits of a Arduino Atmega328p are as follows:


Code:
lockbit 65      00
lockbit 43      11
lockbit 21      11

C               1       divide clock by 8 disabled
B               1       clock output disabled
KLA987          111111  Ext, clock Osc.freq. 8.0- Mhz

K               1
J               1
I               0       SPI enabled
H               1
G               1

R               10      bootsize 256 words (this is strange, the bootstrap starts at &H7800)
Q               1       select reset vector
 


Put in your Bascom-AVR code the $loadersize statement:

Example:


Code:
'Arduino Duemilanove test - Atmega328p

$regfile "m328pdef.dat"
$crystal = 16000000

$loadersize = &H800

Config Portd.4 = Output
Config Portd.5 = Output
Config Portd.6 = Output
Config Portd.7 = Output

Do

Set Portd.4
Reset Portd.5
Reset Portd.6
Set Portd.7
Wait 1
Reset Portd.4
Set Portd.5
Set Portd.6
Reset Portd.7
Wait 1
Loop

End
 




To be continued
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Kiedro

Bascom Member



Joined: 08 Mar 2006
Posts: 81

germany.gif
PostPosted: Tue Mar 09, 2010 12:54 pm    Post subject: Reply with quote

Thanks Ben, this will help people in several projects!
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Jun 11, 2010 8:58 pm    Post subject: Arduino Diecimila and AVRDUDE Reply with quote

Checked if I could program the Arduino Duemilanove with an Atmega168 on 16 Mhz with a Diecimila bootloader. It works. Here the details:

Code:
avrdude.exe
-v -F -Cc:\avrdude.conf -p m168 -P com3 -c STK500v1 -b 19200 -Uflash:w:{FILE}:a
 


Put the avrdude.conf in the root (c: ) directory.

Fusebits of the Atmega168
C divide by 8 disabled
KLA987 111111
Q select boot vector
RS bootloader 1024 words

Put your USB-serial port on a COM-port somewhere between 1 and 9.

Just a compile of your program, and a flash will do the job. No reset needed.

Here the hex-file of the bootloader.

http://members.home.nl/bzijlstra/software/examples/atmegaboot_168_diecimila.hex

http://members.home.nl/bzijlstra/software/examples/avrdude.conf


Have fun
Ben Zijlstra

And another tip: when using different boards with avrdude, create several batchfiles with the right parameters. And call the right batchfile as external programmer.
Back to top
View user's profile Visit poster's website
Kiedro

Bascom Member



Joined: 08 Mar 2006
Posts: 81

germany.gif
PostPosted: Sat Jun 12, 2010 10:49 am    Post subject: Razor Reply with quote

Hi Ben,

thanks again! I guess that not only me would highly appreciate if you could take a look to SFE's Razor 9DOF you mention on your homepage. Can you find out which bootloader is involved? Is the bootloader burned by SFE non standard? Several people (including from the Arduino camp) found that SW updates or alternative SW requires a reflashing of the bootloader before. This is a pity because it means to put an ISP header onto the Razor making it less "razorized".

Kind regards,
Natalius
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Jun 12, 2010 1:15 pm    Post subject: 9DOF with bluetooth.... Reply with quote

Natalius

I also have seen the standard settings (atmega328) was not correct programming the 9DOF Razor IMU. So tried every other settings to find out that Arduino Mini or Nano (if I remembered correctly) was oke. So I was able to burn the Arduino software in the 9DOF without any problem.

If you wait a bit, I am in the middle of making a 9DOF shield for the Arduino Mega including bluetooth.... A board that will also run standalone.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Jul 23, 2010 2:06 pm    Post subject: 9DOF board ready... Reply with quote



This is a shield for the Arduino Mega. And on it we have to put these components: ADXL345 3-axis accelerometer, LY530ALH low power, single axis yaw gyro, LPR530AL dual axis gyro (pitch and roll), HMC5843 3 axis electronic compass, BTM220 bluetooth module class 1 or BTM112 bluetooth module class 2. To have it work without the Arduino Mega it is also possible to fit Atmega328 and FT232RL USB to UART bridge. As display we have choosen the 132 x 132 color Nokia display.

Going to be busy writing the Bascom-AVR software the next days...

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Kiedro

Bascom Member



Joined: 08 Mar 2006
Posts: 81

germany.gif
PostPosted: Sat Jul 24, 2010 10:17 am    Post subject: Reply with quote

Looks great!!! As you are using the same MEMS components as on the Razor 9DOF, you may save coding time by starting from the Kixrazor code. If you have time to try it out: Please test it without the HP filters first. There are hints that performance is better then at 16 MHz. I never tried it out as the current Razors come with 8 MHz crystals.
Regards,
Natalius
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Jul 24, 2010 10:48 am    Post subject: Bluetooth on Arduino oke... Reply with quote

Bluetooth part is working!! BTM-112 or BTM-220 can be chosen. 30 or 100 meters. And about the sensors, these are REAL small to solder... The HMC5843, you got to have a steady hand Very Happy



Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Mon Jul 26, 2010 2:35 am    Post subject: Roll, Pitch and Yaw... Reply with quote

We got it working, a Arduino Mega 9DOF Bluetooth board.

Here a picture:


Getting the sensors on the board was a difficult task, but we managed. These sensors are used in cell-phones so they are very small. Solder paste did the trick. And another trick was the I2c-scanner I wrote a few years back. We could see the ADXL345 and the HMC5843 on the I2c-bus so we knew connections were oke. A few adaptions on the KixRazor software and it is running very well.

The python result:



Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Tue Jul 27, 2010 9:53 am    Post subject: To the movies.... Reply with quote

Time for some action Shocked

Movie of a working Arduino Mega 9DOF Bluetooth Shield.

http://members.home.nl/hobbycorner/movies/9DOF_Arduino.wmv

The software loaded is the Arduino software from www.sparkfun.com, it is running a bit smoother than the KixRazor Bascom-AVR software. Have to dig into that.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Kiedro

Bascom Member



Joined: 08 Mar 2006
Posts: 81

germany.gif
PostPosted: Tue Jul 27, 2010 9:26 pm    Post subject: Reply with quote

Hi Ben,

video looks fine to me - but the time response looks a bit more delayed compared to the Kixrazor. The difference in "smoothness" is a matter of cycle time and the question of how the data are transferred to the receiving end - kixing is senseable more responsive but requires a code change at the Python end.

To get it more smoothed just go from 20ms to 22 or 25 ms.

There are of course code differences - Doug uses an interrupt every time the ADC is ready for a new conversion - I was afraid of the overhead here - so my code philosophy was "Let it flow - but know the time precisely". This may also have som consequences on smoothness as "grouped sampling" and "equidistant sampling" can make a littele difference. For a pure Bascom code I think it is better to be aware of overheads. Adrian suggested (unfortunately our discussion was not posted for public reading - now I see that we should have posted better) that a timer based ISR ADC-poll might be a good compromize. We didn't try it out because we both found that there are some fundamental issues of the DCM "in air" needed to be resolved first. It has to do with effects that come into existence, once the Razor is not anymore a tilt sensor on the accel side - and the way PID is done within DCM.

Further differences are related to different ways Bascom and Arduino deals with the HW - but honestly - I have every reason to trust Mark that Bascom (if handled the right way) is better or at least not inferior than/to Arduino. I could move in both directions now - but I like Bascom and prefer to "bascomize" Arduino code (if necessary) instead of Arduinizing Bascom code. Some routines (eg matrix inversion needed for the Kalman filtering) seem to have appeared in a bascomized variant faster than at Arduino - and our X_mega fans (eg S_Sergiu) are also quite pushy. I could translate the AR7212 functionality into Arduino and contribute to the ArduPilot Mega now. But why? It is a matter to be able to continue talking "mother language" to me.

So I do understand that your mission, Ben, is to enable Bascomers to use Arduino-HW. This is wonderful, timely, and necessary. Please continue!

If you think about a mini-series for your shield - put me onto your customer list. I made progress with SMD soldering - but - honestly - it is still a pain in the neck - eyes and hands were far better couple of years ago.

All the best,

Natalius
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Tue Jul 27, 2010 9:40 pm    Post subject: KixRazor Reply with quote

Natalius

Your KixRazor software is amazing. I think it has taken a lot of time to Bascomize the code. The board is just 2 days finished so we had not have enough time to check every detail. I am working on the bluetooth part now. In Bascom-AVR all is working, I can connect to a GPS mouse as a test, and also in Arduino code I have it running now. Must connect however to the build-in bluetooth of my laptop and working on that now.

And about a small series. Putting the sensors on is a difficult part. We are talking about 45 dollars on sensors and about 13 euros for the bluetooth, so the board is not real cheap. We will try the standalone function first, and a BTM-220 instead of a BTM-112, and then have a look how to carry on.

Made a few tools to check the sensors in Bascom-AVR. Will publish them later on.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Jul 28, 2010 8:04 pm    Post subject: Bluetooth running.... Reply with quote

Hope I am not boring.... Bluetooth working. Wrote a small Bascom-AVR program to put the Bluetooth module in slave mode, let it work on 57600 baud and have given it a name. So now we have a invisible wire between the Arduino Mega 9DOF Bluetooth and the PC/Laptop with the Python software.

On my weblog more details http://benshobbycorner.nl





Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Kiedro

Bascom Member



Joined: 08 Mar 2006
Posts: 81

germany.gif
PostPosted: Thu Jul 29, 2010 10:45 pm    Post subject: Reply with quote

You don't bore at all. Keep on, Ben! Natalius
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Jul 30, 2010 12:14 am    Post subject: Bluetooth class 1 and class 2 Reply with quote



Left top, Arduino Mega 9DOF Bluetooth with Class 2 BTM-112 bluetooth module. Left bottom, one with a Class 1 BTM-222 bluetooth, and at the right a complete board with BTM-112. We still have to make a standalone with SMD Atmega328p. Parts are on their way…. The antennas, 31 mm. These are all the same boards, on the top a BTM-112 or on the bottom a BTM-222. 30 meters or 100 meters.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum