Go Down

Topic: urgent help needed (converting PDE file to hex) (Read 849 times) previous topic - next topic

Eitan Waks

hi,
I have written a code for a company and have been able to program several chips using my arduino board. The company now wants to program several hundred chips. In order to do so they want a hex file.

I tried outputting a hex file but apparently it's not working correctly. Can anyone please try to output a hex file for me and send back to me?

I need to program the following chip: ATMega8-16.
The code is attached.

Thank you very much for your help!!!

PS are there any other forums that I should try posting in?

CODE:

const int Button = 2;  // pushbutton
const int MOT1_D1 = 3;  // motor1 disable 1
const int MOT1_D2 = 4;  // motor1 disable 2
const int MOT1_IN1 = 5;  // motor1 input 1
const int MOT1_IN2 = 6;  // motor1 input 2
const int Limit1 = 7;  // left limit switch
const int Limit2 = 8;  // right limit switch
const int MOT2_D1 = 9;  // motor2 disable 1
const int MOT2_D2 = 10;  // motor2 disable 2
const int MOT2_IN1 = 11;  // motor2 input 1
const int MOT2_IN2 = 12;  // motor2 input 2
const int LED = 13;    // LED
const int Jumper = 14;  // jumper
const int Input2 = 15;  // input 2
const int Input3 = 16;  // input 3
// variables
int DoorState = 0;  // 0 -> door closed, 1 -> door open
int buttonstate = 0;
int input2state = 0;
int input3state = 0;
int val11 = 0;
int val21 = 0;
int val31 = 0;
int val12 = 0;
int val22 = 0;
int val32 = 0;
// constants
const int closed = 0;
const int open = 1;
const int debounce_time = 100;
const int limit_delay = 4000;
const int motor1_extend_runtime = 4000;
const int motor1_retract_runtime = 4000;
const int motor2_extend_runtime = 6000;
const int motor2_retract_runtime = 6000;
const int delay_before_close = 3000;
const int delay_between_motors = 500;

void setup(){
 pinMode(Limit1, INPUT);
 pinMode(Limit2, INPUT);
 pinMode(Button, INPUT);
 pinMode(Jumper, INPUT);
 pinMode(Input2, INPUT);
 pinMode(Input3, INPUT);
 
 pinMode(LED, OUTPUT);

 pinMode(MOT1_D1, OUTPUT);
 digitalWrite(MOT1_D1, LOW);
 pinMode(MOT1_D2, OUTPUT);
 digitalWrite(MOT1_D2, LOW);
 pinMode(MOT1_IN1, OUTPUT);
 digitalWrite(MOT1_IN1, LOW);  
 pinMode(MOT1_IN2, OUTPUT);
 digitalWrite(MOT1_IN2, LOW);
 
 pinMode(MOT2_D1, OUTPUT);
 digitalWrite(MOT2_D1, LOW);
 pinMode(MOT2_D2, OUTPUT);
 digitalWrite(MOT2_D2, LOW);
 pinMode(MOT2_IN1, OUTPUT);
 digitalWrite(MOT2_IN1, LOW);  
 pinMode(MOT2_IN2, OUTPUT);
 digitalWrite(MOT2_IN2, LOW);
 
 
 digitalWrite(LED, LOW);
 digitalWrite(LED, HIGH);
 delay(3000);
 digitalWrite(LED, LOW);
 
 blinks (LED, 10, 100);
 initialize_position (DoorState);

}

void loop(){
 // debounce for inputs
 val11 = digitalRead(Button);
 val21 = digitalRead(Input2);
 val31 = digitalRead(Input3);
 delay(debounce_time); // amount of time for debounce
 val12 = digitalRead(Button);
 val22 = digitalRead(Input2);
 val32 = digitalRead(Input3);
 if ((val11 == LOW) && (val12 == LOW)){
   buttonstate = LOW;
 }
 else {
   buttonstate = HIGH;
 }
 if ((val21 == LOW) && (val22 == LOW)){
   input2state = LOW;
 }
 else {
   input2state = HIGH;
 }
 if ((val31 == LOW) && (val32 == LOW)){
   input3state = LOW;
 }
 else {
   input3state = HIGH;
 }  

 if (digitalRead(Jumper) == HIGH) {
   
   if ((digitalRead(Limit1) == LOW) && (digitalRead(Limit2) == LOW) && ((buttonstate == LOW) || (input2state == LOW) || (input3state == LOW) )){
     extend_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     delay(motor1_extend_runtime);
     DoorState = open;
     stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     delay(delay_before_close);
     if ((digitalRead(Limit1) == LOW) && (digitalRead(Limit2) == LOW)){
       retract_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       delay(motor1_retract_runtime);
       DoorState = closed;
       stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       if ((digitalRead(Limit1) != LOW) || (digitalRead(Limit2) != LOW)){
         extend_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
         delay(motor1_extend_runtime);
         DoorState = open;
         stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       }
     }      
   }
   else
   if ((digitalRead(Limit1) == LOW) && (digitalRead(Limit2) == LOW) && (DoorState == open)){
     delay(limit_delay);
     retract_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     delay(motor1_retract_runtime);
     DoorState = closed;
     stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     if ((digitalRead(Limit1) != LOW) || (digitalRead(Limit2) != LOW)){
       extend_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       delay(motor1_extend_runtime);
       DoorState = open;
       stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     }
   }  
 }
 else
 if (digitalRead(Jumper) == LOW) {
   if ((digitalRead(Limit1) == LOW) && (digitalRead(Limit2) == LOW) && ((buttonstate == LOW) || (input2state == LOW) || (input3state == LOW))){
     extend_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     delay(motor1_extend_runtime);
     DoorState = open;
     stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
     delay(delay_between_motors);
     turn_motor_clockwise (MOT2_D1, MOT2_D2, MOT2_IN1, MOT2_IN2);
     delay(motor2_extend_runtime);
     stop_actuator (MOT2_D1, MOT2_D2, MOT2_IN1, MOT2_IN2);      
     }
   else
   if ((DoorState == open) && ((buttonstate == LOW) || (input2state == LOW) || (input3state == LOW))){
     turn_motor_counterclockwise (MOT2_D1, MOT2_D2, MOT2_IN1, MOT2_IN2);
     delay(motor2_retract_runtime);
     stop_actuator (MOT2_D1, MOT2_D2, MOT2_IN1, MOT2_IN2);
     if ((digitalRead(Limit1) == LOW) || (digitalRead(Limit2) == LOW)){
       retract_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       delay(motor1_retract_runtime);
       DoorState = closed;
       stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       if ((digitalRead(Limit1) != LOW) || (digitalRead(Limit2) != LOW)){
         extend_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
         delay(motor1_extend_runtime);
         DoorState = open;
         stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
       }
     }  
  }
}
}


void blinks (int pin_num, int num_of_blinks, int interval) {
 int i = 0;
 for (i = 0; i<num_of_blinks; i++) {
   digitalWrite(pin_num, HIGH);
   delay (interval/2);
   digitalWrite(pin_num, LOW);
   delay (interval/2);
 }
}  

void initialize_position (int DoorState) {
 while ((digitalRead(Limit1) == HIGH) || (digitalRead(Limit2) == HIGH)) {
   //the program does not proceed until both limit switches are in contact
 }
 // Retract Actuator
 delay(limit_delay);  
 retract_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
 delay(motor1_retract_runtime);
 DoorState = closed;
 stop_actuator (MOT1_D1, MOT1_D2, MOT1_IN1, MOT1_IN2);
}


void extend_actuator (int MOT1_D1, int MOT1_D2, int MOT1_IN1, int MOT1_IN2) {
 digitalWrite(MOT1_D1, LOW);
 digitalWrite(MOT1_D2, HIGH);
 digitalWrite(MOT1_IN1, HIGH);
 digitalWrite(MOT1_IN2, LOW);
 digitalWrite(LED, HIGH);
}


void retract_actuator (int MOT1_D1, int MOT1_D2, int MOT1_IN1, int MOT1_IN2) {
 digitalWrite(MOT1_D1, LOW);
 digitalWrite(MOT1_D2, HIGH);
 digitalWrite(MOT1_IN1, LOW);
 digitalWrite(MOT1_IN2, HIGH);
 digitalWrite(LED, HIGH);
}

/*******************************************************************************************
Function name : stop_actuator
Input:  
Output:
the program stops the actuator
*******************************************************************************************/
void stop_actuator (int MOT1_D1, int MOT1_D2, int MOT1_IN1, int MOT1_IN2) {
 digitalWrite(MOT1_D1, HIGH);
 digitalWrite(MOT1_D2, LOW);
 digitalWrite(MOT1_IN1, LOW);
 digitalWrite(MOT1_IN2, LOW);
 digitalWrite(LED, LOW);
}


void turn_motor_clockwise (int MOT2_D1, int MOT2_D2, int MOT2_IN1, int MOT2_IN2) {
 digitalWrite(MOT2_D1, LOW);
 digitalWrite(MOT2_D2, HIGH);
 digitalWrite(MOT2_IN1, HIGH);
 digitalWrite(MOT2_IN2, LOW);
 digitalWrite(LED, HIGH);
}


void turn_motor_counterclockwise (int MOT2_D1, int MOT2_D2, int MOT2_IN1, int MOT2_IN2) {
 digitalWrite(MOT2_D1, LOW);
 digitalWrite(MOT2_D2, HIGH);
 digitalWrite(MOT2_IN1, LOW);
 digitalWrite(MOT2_IN2, HIGH);
 digitalWrite(LED, HIGH);
}

PaulS

If you are able to upload this code to an Arduino, a hex file was produced. You can find out where by enabling verbose output. There are two ways to do this.

From:http://www.arduino.cc/en/Hacking/BuildProcess
Quote
Also useful is this setting in the main preferences.txt file:

build.verbose: whether or not to print debugging messages while building a sketch (e.g. "false"). If true, will print the complete command line of each external command executed as part of the build process.


The other way is to hold down one of the modifier keys when starting the build process - either ctrl, shift, or alt. I don't remember which.

hector albornoz

Arduino 0021 - BT /w Atmega 168

:100000000C9461000C947E000C947E000C947E0095
:100010000C947E000C947E000C947E000C947E0068
:100020000C947E000C947E000C947E000C947E0058
:100030000C947E000C947E000C947E000C947E0048
:100040000C94BA030C947E000C947E000C947E00F9
:100050000C947E000C947E000C947E000C947E0028
:100060000C947E000C947E00000000002400270009
:100070002A0000000000250028002B0000000000DE
:1000800023002600290004040404040404040202DA
:100090000202020203030303030301020408102007
:1000A0004080010204081020010204081020000012
:1000B0000007000201000003040600000000000029
:1000C000000011241FBECFEFD4E0DEBFCDBF11E092
:1000D000A0E0B1E0EEE1FBE002C005900D92A0309F
:1000E000B107D9F711E0A0E0B1E001C01D92AD3138
:1000F000B107E1F70E945F050C948D050C94000098
:10010000FF920F931F93162F042FF22E60E00E9490
:10011000BC04812F61E00E94BC04802F60E00E943B
:10012000BC048F2D61E00E94BC048DE061E00E9460
:10013000BC041F910F91FF900895FF920F931F939E
:10014000162F042FF22E60E00E94BC04812F61E084
:100150000E94BC04802F61E00E94BC048F2D60E0EF
:100160000E94BC048DE061E00E94BC041F910F91CD
:10017000FF900895FF920F931F93162F042FF22ED6
:1001800061E00E94BC04812F60E00E94BC04802FCB
:1001900060E00E94BC048F2D60E00E94BC048DE0F2
:1001A00060E00E94BC041F910F91FF900895FF92A0
:1001B0000F931F93162F042FF22E60E00E94BC04B1
:1001C000812F61E00E94BC04802F60E00E94BC048B
:1001D0008F2D61E00E94BC048DE061E00E94BC04B0
:1001E0001F910F91FF900895FF920F931F93162F69
:1001F000042FF22E60E00E94BC04812F61E00E9477
:10020000BC04802F61E00E94BC048F2D60E00E943E
:10021000BC048DE061E00E94BC041F910F91FF902F
:10022000089587E00E9410050197D9F388E00E94A5
:1002300010050197B1F360EA7FE080E090E00E9452
:10024000020483E090E064E070E045E050E026E0E6
:1002500030E00E94D70060EA7FE080E090E00E94FA
:10026000020483E090E064E070E045E050E026E0C6
:1002700030E00E94BA000895BF92CF92DF92EF92D1
:10028000FF920F931F93CF93DF93B82E6B01CA0198
:1002900062E070E00E9466057B010027F7FC009594
:1002A000102FC0E0D0E011C08B2D61E00E94BC0493
:1002B000C801B7010E9402048B2D60E00E94BC04BB
:1002C000C801B7010E9402042196CC15DD0564F334
:1002D000DF91CF911F910F91FF90EF90DF90CF9022
:1002E000BF90089582E00E941005909309018093C9
:1002F00008018FE00E94100590930B0180930A0182
:1003000080E10E94100590930D0180930C0164E63A
:1003100070E080E090E00E94020482E00E941005FC
:1003200090930F0180930E018FE00E94100590932F
:1003300011018093100180E10E9410059C019093AF
:100340001301809312018091080190910901892B7A
:1003500059F480910E0190910F01892B29F410928C
:1003600003011092020106C081E090E09093030126
:100370008093020180910A0190910B01892B59F41D
:100380008091100190911101892B29F4109205019F
:100390001092040106C081E090E0909305018093E3
:1003A000040180910C0190910D01892B39F4232BCC
:1003B00029F4109207011092060106C081E090E036
:1003C00090930701809306018EE00E94100501972B
:1003D00009F060C087E00E941005892B09F03FC139
:1003E00088E00E941005892B09F039C18091020133
:1003F00090910301892B69F080910401909105018E
:10040000892B39F08091060190910701892B09F021
:1004100026C183E090E064E070E045E050E026E033
:1004200030E00E94F40060EA7FE080E090E00E940B
:10043000020481E090E0909301018093000183E049
:1004400090E064E070E045E050E026E030E00E949B
:10045000BA0068EB7BE080E090E00E94020487E055
:100460000E941005892B09F007C1AAC088E00E94EC
:100470001005892B09F000C18091000190910101C4
:10048000019709F0F9C060EA7FE080E090E00E9407
:1004900002049CC08EE00E941005892B09F0ECC07C
:1004A00087E00E941005892B09F0DFC088E00E94D8
:1004B0001005892B09F0D9C08091020190910301A8
:1004C000892B69F08091040190910501892B39F005
:1004D0008091060190910701892B09F0C6C083E045
:1004E00090E064E070E045E050E026E030E00E94FB
:1004F000F40060EA7FE080E090E00E94020481E086
:1005000090E0909301018093000183E090E064E02B
:1005100070E045E050E026E030E00E94BA0064EF71
:1005200071E080E090E00E94020489E090E06AE0DF
:1005300070E04BE050E02CE030E00E949D0060E76E
:1005400077E180E090E00E94020489E090E06AE0B8
:1005500070E04BE050E02CE030E07EC08091020182
:1005600090910301892B69F080910401909105011C
:10057000892B39F08091060190910701892B09F0B0
:100580007BC089E090E06AE070E04BE050E02CE056
:1005900030E00E94800060E777E180E090E00E9418
:1005A000020489E090E06AE070E04BE050E02CE06B
:1005B00030E00E94BA0087E00E941005892B31F0DC
:1005C00088E00E941005892B09F056C083E090E076
:1005D00064E070E045E050E026E030E00E94D700A3
:1005E00060EA7FE080E090E00E9402041092010146
:1005F0001092000183E090E064E070E045E050E09C
:1006000026E030E00E94BA0087E00E941005892BA6
:1006100029F488E00E941005892B71F183E090E0B5
:1006200064E070E045E050E026E030E00E94F40035
:1006300060EA7FE080E090E00E94020481E090E0C8
:10064000909301018093000183E090E064E070E00A
:1006500045E050E026E030E00E94BA00089587E0CF
:100660000E941005892B41F401CF809100019091E7
:100670000101019709F472CF089587E060E00E94BC
:10068000960488E060E00E94960482E060E00E94A8
:1006900096048EE060E00E9496048FE060E00E9485
:1006A000960480E160E00E9496048DE061E00E9483
:1006B000960483E061E00E94960483E060E00E947B
:1006C000BC0484E061E00E94960484E060E00E9443
:1006D000BC0485E061E00E94960485E060E00E9431
:1006E000BC0486E061E00E94960486E060E00E941F
:1006F000BC0489E061E00E94960489E060E00E9409
:10070000BC048AE061E00E9496048AE060E00E94F6
:10071000BC048BE061E00E9496048BE060E00E94E4
:10072000BC048CE061E00E9496048CE060E00E94D2
:10073000BC048DE060E00E94BC048DE061E00E949A
:10074000BC0468EB7BE080E090E00E9402048DE056
:1007500060E00E94BC048DE090E06AE070E044E656
:1007600050E00E943C0180910001909101010E94A3
:10077000110108951F920F920FB60F9211242F931B
:100780003F938F939F93AF93BF9380911801909164
:100790001901A0911A01B0911B0130911C01019621
:1007A000A11DB11D232F2D5F2D3720F02D57019650
:1007B000A11DB11D20931C01809318019093190174
:1007C000A0931A01B0931B0180911401909115011F
:1007D000A0911601B09117010196A11DB11D809342
:1007E000140190931501A0931601B0931701BF91C6
:1007F000AF919F918F913F912F910F900FBE0F90CE
:100800001F9018959B01AC017FB7F894809114015B
:1008100090911501A0911601B091170166B5A89BA2
:1008200005C06F3F19F00196A11DB11D7FBFBA2F02
:10083000A92F982F8827860F911DA11DB11D62E059
:10084000880F991FAA1FBB1F6A95D1F7BC012DC045
:10085000FFB7F8948091140190911501A0911601B1
:10086000B0911701E6B5A89B05C0EF3F19F00196BE
:10087000A11DB11DFFBFBA2FA92F982F88278E0F5A
:10088000911DA11DB11DE2E0880F991FAA1FBB1F7A
:10089000EA95D1F7861B970B885E9340C8F22150EA
:1008A00030404040504068517C4F21153105410592
:1008B000510571F60895789484B5826084BD84B53D
:1008C000816084BD85B5826085BD85B5816085BD4B
:1008D000EEE6F0E0808181608083E1E8F0E0108264
:1008E000808182608083808181608083E0E8F0E0A5
:1008F000808181608083E1EBF0E08081846080838F
:10090000E0EBF0E0808181608083EAE7F0E08081C5
:100910008460808380818260808380818160808325
:100920008081806880831092C1000895482F50E034
:10093000CA0186569F4FFC0124914A575F4FFA0126
:1009400084918823C1F0E82FF0E0EE0FFF1FE859F3
:10095000FF4FA591B491662341F49FB7F8948C9111
:10096000209582238C939FBF08959FB7F8948C9114
:10097000822B8C939FBF0895482F50E0CA01825567
:100980009F4FFC012491CA0186569F4FFC01349170
:100990004A575F4FFA019491992309F440C02223EA
:1009A00031F1233021F4809180008F7705C024300D
:1009B00031F4809180008F7D8093800018C02130B9
:1009C00019F484B58F7704C0223021F484B58F7D6B
:1009D00084BD0DC0263021F48091B0008F7705C012
:1009E000273029F48091B0008F7D8093B000E92FEB
:1009F000F0E0EE0FFF1FEE58FF4FA591B491662374
:100A000041F49FB7F8948C91309583238C939FBFCA
:100A100008959FB7F8948C91832B8C939FBF089572
:100A2000682F70E0CB0182559F4FFC012491CB01D0
:100A300086569F4FFC0144916A577F4FFB0194916A
:100A4000992319F420E030E038C0222331F123301B
:100A500021F4809180008F7705C0243031F480919B
:100A600080008F7D8093800018C0213019F484B5F8
:100A70008F7704C0223021F484B58F7D84BD0DC0F2
:100A8000263021F48091B0008F7705C0273029F4FB
:100A90008091B0008F7D8093B000892F90E0880F07
:100AA000991F84589F4FFC01A591B4918C9120E02F
:100AB00030E0842311F021E030E0C90108950E9464
:100AC0005B040E943D030E947201FDCF97FB092E3B
:100AD00007260AD077FD04D00CD006D000201AF4E7
:100AE000709561957F4F0895F6F7909581959F4F8A
:100AF0000895AA1BBB1B51E107C0AA1FBB1FA61765
:100B0000B70710F0A61BB70B881F991F5A95A9F7B6
:0E0B100080959095BC01CD010895F894FFCF1B
:00000001FF

Go Up