Jump to content
  • 0

Lwclone On Arduino Mega 2560


cyclemat

Question

Here comes the LWClone on Arduino MEGA 2560

 

How to Compile

Windows Prerequisites

On Windows, you will need a copy of the latest Atmel Toolchain, either downloaded 
and installed as a standalone package, or installed as part of Atmel Studio. 
You will need to ensure that the "bin" directory of the toolchain is available 
in your system's PATH environment variable.

In addition, you will need to install a ported version of the ZSH or BASH *nix shells, 
and a standard set of *nix utilities such as cut, find and sed. 
These can be found in the "basic" system package of the of the MinGW installer (http://www.mingw.org). 
Once installed, add the "msys\1.0\bin" of the MinGW installation folder is added 
to your system's PATH environment variable.

The bootloaders currently also require the "bc" application, 
which can be installed from http://gnuwin32.sourceforge.net/downlinks/bc.php. 
Once installed add the "GnuWin32\bin" path of the GnuWin32 installation folder 
to your system's PATH environment variable.

Linux Prerequisites

On Linux systems you will need to install the latest Linux distribution 
of the standalone Atmel Toolchain from the Atmel website for general development, 
or use the latest avr-libc and avr-gcc packages for your chosen distribution's package 
manager. For full device support, the Atmel standalone package is recommended.

How 2 Flash

Connect your Arduino to USB and look witch comport it has
Start Flash Main Chip Arduino Mega to LW.bat
enter your Comport e.g com2 or com32 what ever
Remove USB
Connect your USBASP to the ISP header behind the USB port
Start Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to LW.bat
Connect The USB port wait for reorgination the Device 
Start Change ArduLW ID.bat
Enter your LEDWIZ ID e.g. 1 or 2 up to 16
That is it test it with Visualpinball an Pinmame/DOF

 have make New packages 23.01.2016

 

https://mega.nz/#F!bdZHVaxK!3WmePgTED-3xQp8oj-ZfOA

 

one package with inverted LED ports so that High ist normal and low is on ( for the Relaisboards from ebay)

 

 

For Boards that say it gives problems with The STK500 Timeout Error Here ist a Short way to fix it !?!?

 

 

1. Connect the USBASP to the ISP connector behind the USB Port.

2.Start the  "0. Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to Arduino.bat"

 

3. Connect the USBASP to the Second ISP port

4. Start the "Flash m2560 Unlock fuses, erase, verify - with USBASP Dongle.bat"

5. Start the "Flash m2560 Write the bootloader, set the lock fuse, verify  - with USBASP Dongle.bat"

 

 

Now you can flash it normaly

 

when the flash with the USB ASP didnt work test to bridge the GND point on the 10->6 Pole Converter

 

FOR HELP PLEASE POST YOUR PINMAP.H AS CODE AND WHEN YOU HAVE COMPILING PROBLEMS POST YOUR OUTPUT AS CODE SO I CAN BETTER

HELP

 

So have make a little Video tutorial don`t say anything about my english have do my best.

 

 

 

 

 

Link to comment
Share on other sites

222 answers to this question

Recommended Posts

  • 0

The leds, and relays are off at powerup.

It's like it should be, they are activated by toggling the output ports on the ledwiz.

Do you have the name and number of your board. I can have a look at it and see if I can find a schematic.

Link to comment
Share on other sites

  • 0

jep have the same idea but i cant make it no idea how i can  make the calibration routin when you have an idea and you can patch it pleeeease Help iam work in the momentan @ the Driver PCB

 

 

the boards come this we and i had make a stupid layer change @ last save and now that !

 

https://dl.dropbox.com/s/gww1ckv1zqi1dff/IMG-20141107-WA0000.jpg?dl=0

Link to comment
Share on other sites

  • 0

Little Xmas Package for your Arduino Ready to Flash 

	_map_( E, 4,    KEY_5,			   	0) /* ( OC3B/INT4 )         Digital pin 2 (PWM) */ \
	_map_( E, 5,    KEY_4,			  	0) /* ( OC3C/INT5 )         Digital pin 3 (PWM) */ \
	_map_( G, 5,    KEY_3,			 	0) /* ( OC0B )              Digital pin 4 (PWM) */ \
	_map_( E, 3,    KEY_2,				0) /* ( OC3A/AIN1 )         Digital pin 5 (PWM) */ \
	_map_( H, 3,    KEY_1,		        0) /* ( OC4A )              Digital pin 6 (PWM) */ \
	_map_( H, 4,    KEY_Enter,			0) /* ( OC4B )              Digital pin 7 (PWM) */ \
	_map_( H, 5,    KEY_Esc,           	0) /* ( OC4C )              Digital pin 8 (PWM) */ \
	_map_( H, 6,    MOD_RightControl,   0) /* ( OC2B )              Digital pin 9 (PWM) */ \
	_map_( B, 4,    MOD_LeftControl,	0) /* ( OC2A/PCINT4 )       Digital pin 10 (PWM) */ \
	_map_( B, 5,    MOD_RightShift,		0) /* ( OC1A/PCINT5 )       Digital pin 11 (PWM) */ \
	_map_( B, 6,    MOD_LeftShift,		0) /* ( OC1B/PCINT6 )       Digital pin 12 (PWM) */ \
	_map_( B, 7,    0,          		0) /* ( OC0A/OC1C/PCINT7 )  Digital pin 13 (PWM) */ \
	_map_( J, 1,    KEY_7,				0) /* ( TXD3/PCINT10 )      Digital pin 14 (TX3) */ \
	_map_( J, 0,	KEY_8,				0) /* ( RXD3/PCINT9 )       Digital pin 15 (RX3) */ \
	_map_( H, 1,    KEY_9,				0) /* ( TXD2 )              Digital pin 16 (TX2) */ \
	_map_( H, 0,    KEY_0,				0) /* ( RXD2 )              Digital pin 17 (RX2) */ \
	_map_( D, 3,    KEY_End,			0) /* ( TXD1 )              Digital pin 18 (RX2) */ \
	_map_( D, 2,    KEY_Home,			0) /* ( RXD1 )              Digital pin 19 (RX2) */ \
	_map_( D, 1,    KEY_F1,				0) /* ( SDA/INT1 )          Digital pin 20 (SDA) */ \
	_map_( D, 0,    KEY_F3,				0) /* ( SCL/INT0 )          Digital pin 21 (SCL) */ \
	_map_( F, 4,    KEY_8,				0) /* 				        Analog pin 4 */ \
	_map_( F, 5,    KEY_9,				0) /* ( ADC5/TMS )          Analog pin 5 */ \
	_map_( F, 6,    KEY_0,				0) /* ( ADC6 )              Analog pin 6 */ \
	_map_( F, 7,    KEY_End,				0) /* ( ADC7 )              Analog pin 7 */ \
	_map_( K, 0,    KEY_Home,			0) /* ( ADC8/PCINT16 )      Analog pin 8 */ \
	_map_( K, 1,    KEY_F1,			0) /* ( ADC9/PCINT17 )      Analog pin 9 */ \
	_map_( K, 2,    KEY_F3,				0) /* ( ADC10/PCINT18 )     Analog pin 10 */ \
	_map_( K, 3,    0,				0) /* ( ADC11/PCINT19 )     Analog pin 11 */ \
	_map_( K, 4,    AG_Button1,			0) /* ( ADC12/PCINT20 )     Analog pin 12 */ \
	_map_( K, 5,    AG_Button2,			0) /* ( ADC13/PCINT21 )     Analog pin 13 */ \
	_map_( K, 6,    AG_Button3,			0) /* ( ADC14/PCINT22 )     Analog pin 14 */ \
	_map_( K, 7,    AG_Button4,			0) /* ( ADC15/PCINT23 )     Analog pin 15 */ \

https://mega.co.nz/#F!XIRASLjY!ym9W9bJHsWZARDYBOlku-w

Link to comment
Share on other sites

  • 0

Hi cyclemat,

 

thank you very much for your great project!

Unfortunately I´m not able to get it running. Maybe someone/you can help me out.

 

When I try to do the first step "0. Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to Arduino.bat", it always fails with efuse error.

See picture attached.

 

 

Some more infos:

I got a Arduino 2560 rev3 from ebay. (most probably a clone)

I did some tries with "dfu-programmer" and partly succeded.

Digital outputs work, Joystick functions remain dead. Maybe due to missing fuse settings while using dfu-programmer.?

 

ANY help would be very welcome :-)

 

Thank you very much in advance!

post-5179-0-04967600-1420653067_thumb.png

Link to comment
Share on other sites

  • 0

Hi cyclemat,

 

thank you very much for your great project!

Unfortunately I´m not able to get it running. Maybe someone/you can help me out.

 

When I try to do the first step "0. Flash 8u2 - 16u2 Arduino Mega - with USBASP Dongle to Arduino.bat", it always fails with efuse error.

See picture attached.

 

 

Some more infos:

I got a Arduino 2560 rev3 from ebay. (most probably a clone)

I did some tries with "dfu-programmer" and partly succeded.

Digital outputs work, Joystick functions remain dead. Maybe due to missing fuse settings while using dfu-programmer.?

 

ANY help would be very welcome :-)

 

Thank you very much in advance!

do you use a USBasp?

Link to comment
Share on other sites

  • 0

Yes, I use USBasp.

Here it fail with efuse error. Device will not be recognised then...

 

When I get my Arduino to DFU mode and try to programm with "dfu-programmer" everything works just fine.

It now shows up with a COM port.

I can programm the main-chip...

 

Try to do the final step (flash it to Ledwiz) again with USBasp -> it fails with efuse error...

Try it with DFU mode and dfu-programmer, it works.

 

This done:

- all digital outputs work just fine

- all keyboard commands work just fine

- Joystick axes don´t work at all

- Joystick buttons work partly (only button 1,2,3 work; rest is dead)

 

By the way... Keymapping is untouched. I used the package as is...

Link to comment
Share on other sites

  • 0

Yes, I use USBasp.

Here it fail with efuse error. Device will not be recognised then...

 

When I get my Arduino to DFU mode and try to programm with "dfu-programmer" everything works just fine.

It now shows up with a COM port.

I can programm the main-chip...

 

Try to do the final step (flash it to Ledwiz) again with USBasp -> it fails with efuse error...

Try it with DFU mode and dfu-programmer, it works.

 

This done:

- all digital outputs work just fine

- all keyboard commands work just fine

- Joystick axes don´t work at all

- Joystick buttons work partly (only button 1,2,3 work; rest is dead)

 

By the way... Keymapping is untouched. I used the package as is...

Could you post a screenshot of the error message you are getting!

 

thanks!

Link to comment
Share on other sites

  • 0

Hi,

 

post #84 has a screenshot attached.

 

I think I narrowed down the problem at least a bit...

 

when using dfu-programmer while only writing the efuse bit, it behaves like follows:

 

- i can write several values to efuse

- e.g. 0xFC, 0xFD .... and several other values can be writen -> verification ok

- only value not working is 0xF4

 

0xF4 represents the extended fuse settings:

 

HWBE "set"

BODLEVEL 2 "not set"

BODLEVEL 1 "set"

BODLEVEL 1 "set"

 

It seems all configurations are possible, beside the desired one.

(from AVR fuse Calculator, see "engbedded"-homepage; controler atmega16u2.)

Link to comment
Share on other sites

  • 0
  • Content Provider
Hello Cyclemat!

I have a problem .. I followed the steps to program the Arduino but LedwizClon works in a reverse way.

 

For example, in the port 1 in SimpleLEDTest LED that port is turned off, and when I change to port 2 LED 1  turned on.

 

Read the thread I saw that this problem is solved by programming with USBasp, but I'm programming the Arduino with this programmer USBasp.

 

I followed the steps mentioned by you..

 

1: Flash Main Chip to Arduino Mega LW.bat with USB port

 

2. Flash 8U2 - 16u2 Arduino Mega - with USBASP Dongle to LW.bat with the programmer USBasp

 

This is fine?

 

Cheers, Javier..

Link to comment
Share on other sites

  • 0

sorry that i was away iam hard in work

 

that was you mean can only work  when yout have change

	_map_( A, 0, 0 ) /* ( AD0 )               Digital pin 22 */ \
	_map_( A, 2, 0 ) /* ( AD2 )               Digital pin 24 */ \
	_map_( A, 4, 0 ) /* ( AD4 )               Digital pin 26 */ \

to

	_map_( A, 0, 1 ) /* ( AD0 )               Digital pin 22 */ \
	_map_( A, 2, 1 ) /* ( AD2 )               Digital pin 24 */ \
	_map_( A, 4, 1 ) /* ( AD4 )               Digital pin 26 */ \

the "0" or "1" behind the ports in the config are for the normal state of the port if its "0" the Port is Low (OFF) when its "1" its High (ON)

 

when you use a Relais board from ebay like Saintsmart you must change the pinmap.h and compile it new to have the Relais of in normal state the needs High inputs!

 

 

I will Upload all new but my account is dead 

Link to comment
Share on other sites

  • 0
  • Content Provider

I apologize for my ignorance, but it's okay like this?

 

 

 

#define LED_MAPPING_TABLE(_map_) \   \   _map_( A, 0, 1 ) /* ( AD0 ) Digital pin 22 */ \   _map_( A, 1, 1 ) /* ( AD1 ) Digital pin 23 */ \   _map_( A, 2, 1 ) /* ( AD2 ) Digital pin 24 */ \   _map_( A, 3, 1 ) /* ( AD3 ) Digital pin 25 */ \   _map_( A, 4, 1 ) /* ( AD4 ) Digital pin 26 */ \   _map_( A, 5, 1 ) /* ( AD5 ) Digital pin 27 */ \   _map_( A, 6, 1 ) /* ( AD6 ) Digital pin 28 */ \   _map_( A, 7, 1 ) /* ( AD7 ) Digital pin 29 */ \   _map_( C, 7, 1 ) /* ( A15 ) Digital pin 30 */ \   _map_( C, 6, 1 ) /* ( A14 ) Digital pin 31 */ \   _map_( C, 5, 1 ) /* ( A13 ) Digital pin 32 */ \   _map_( C, 4, 1 ) /* ( A12 ) Digital pin 33 */ \   _map_( C, 3, 1 ) /* ( A11 ) Digital pin 34 */ \   _map_( C, 2, 1 ) /* ( A10 ) Digital pin 35 */ \   _map_( C, 1, 1 ) /* ( A9 ) Digital pin 36 */ \   _map_( C, 0, 1 ) /* ( A8 ) Digital pin 37 */ \   _map_( D, 7, 1 ) /* ( T0 ) Digital pin 38 */ \   _map_( G, 2, 1 ) /* ( ALE ) Digital pin 39 */ \   _map_( G, 1, 1 ) /* ( RD ) Digital pin 40 */ \   _map_( G, 0, 1 ) /* ( WR ) Digital pin 41 */ \   _map_( L, 7, 1 ) /* Digital pin 42 */ \   _map_( L, 6, 1 ) /* Digital pin 43 */ \   _map_( L, 5, 1 ) /* ( OC5C ) Digital pin 44 (PWM) */ \   _map_( L, 4, 1 ) /* ( OC5B ) Digital pin 45 (PWM) */ \   _map_( L, 3, 1 ) /* ( OC5A ) Digital pin 46 (PWM) */ \   _map_( L, 2, 1 ) /* ( T5 ) Digital pin 47 */ \   _map_( L, 1, 1 ) /* ( ICP5 ) Digital pin 48 */ \   _map_( L, 0, 1 ) /* ( ICP4 ) Digital pin 49 */ \   _map_( B, 3, 1 ) /* ( MISO/PCINT3 ) Digital pin 50 (MISO) */ \   _map_( B, 2, 1 ) /* ( MOSI/PCINT2 ) Digital pin 51 (MOSI) */ \   _map_( B, 1, 1 ) /* ( SCK/PCINT1 ) Digital pin 52 (SCK) */ \   _map_( B, 0, 1 ) /* ( SS/PCINT0 ) Digital pin 53 (SS) */ \

 

 

 

 

that way I do not work  :(

 

 

And this does not work otherwise. :(

 

 

 
#define LED_MAPPING_TABLE(_map_) \   \   _map_( A, 0, 0 ) /* ( AD0 ) Digital pin 22 */ \   _map_( A, 1, 0 ) /* ( AD1 ) Digital pin 23 */ \   _map_( A, 2, 0 ) /* ( AD2 ) Digital pin 24 */ \   _map_( A, 3, 0 ) /* ( AD3 ) Digital pin 25 */ \   _map_( A, 4, 0 ) /* ( AD4 ) Digital pin 26 */ \   _map_( A, 5, 0 ) /* ( AD5 ) Digital pin 27 */ \   _map_( A, 6, 0 ) /* ( AD6 ) Digital pin 28 */ \   _map_( A, 7, 0 ) /* ( AD7 ) Digital pin 29 */ \   _map_( C, 7, 0 ) /* ( A15 ) Digital pin 30 */ \   _map_( C, 6, 0 ) /* ( A14 ) Digital pin 31 */ \   _map_( C, 5, 0 ) /* ( A13 ) Digital pin 32 */ \   _map_( C, 4, 0 ) /* ( A12 ) Digital pin 33 */ \   _map_( C, 3, 0 ) /* ( A11 ) Digital pin 34 */ \   _map_( C, 2, 0 ) /* ( A10 ) Digital pin 35 */ \   _map_( C, 1, 0 ) /* ( A9 ) Digital pin 36 */ \   _map_( C, 0, 0 ) /* ( A8 ) Digital pin 37 */ \   _map_( D, 7, 0 ) /* ( T0 ) Digital pin 38 */ \   _map_( G, 2, 0 ) /* ( ALE ) Digital pin 39 */ \   _map_( G, 1, 0 ) /* ( RD ) Digital pin 40 */ \   _map_( G, 0, 0 ) /* ( WR ) Digital pin 41 */ \   _map_( L, 7, 0 ) /* Digital pin 42 */ \   _map_( L, 6, 0 ) /* Digital pin 43 */ \   _map_( L, 5, 0 ) /* ( OC5C ) Digital pin 44 (PWM) */ \   _map_( L, 4, 0 ) /* ( OC5B ) Digital pin 45 (PWM) */ \   _map_( L, 3, 0 ) /* ( OC5A ) Digital pin 46 (PWM) */ \   _map_( L, 2, 0 ) /* ( T5 ) Digital pin 47 */ \   _map_( L, 1, 0 ) /* ( ICP5 ) Digital pin 48 */ \   _map_( L, 0, 0 ) /* ( ICP4 ) Digital pin 49 */ \   _map_( B, 3, 0 ) /* ( MISO/PCINT3 ) Digital pin 50 (MISO) */ \   _map_( B, 2, 0 ) /* ( MOSI/PCINT2 ) Digital pin 51 (MOSI) */ \   _map_( B, 1, 0 ) /* ( SCK/PCINT1 ) Digital pin 52 (SCK) */ \   _map_( B, 0, 0 ) /* ( SS/PCINT0 ) Digital pin 53 (SS) */ \

 

 

I do not know what to do.

 

Thank you for your patience.

Link to comment
Share on other sites

  • 0

stupi question have you compiled the source ? witch windows do you use when you have compiled the system. have you test to compile it on a other system like windows XP onetimes i had the problem that the compiling didnt work on my win7 PC

Link to comment
Share on other sites

  • 0
  • Content Provider
This is what I do:
 
on page github.com, I go with my account to your project and firware section, I edit the values of the LED "0" to "1".
Finally downloaded as .Zip File
 
 
 
post-362-0-82947100-1440347769_thumb.jpg
 
 
 
 
post-362-0-63227900-1440347813_thumb.jpg
 
 
 
 
 
Perform the process on another computer but have the same result.
 
 
Cheers, Javier..

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...