go away spammer

Author Topic: request suggestion in basic c code [ post #18]  (Read 6750 times)

0 Members and 1 Guest are viewing this topic.

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
request suggestion in basic c code [ post #18]
« on: February 28, 2012, 08:09:32 AM »
Hi all,
I am using Win vista business version, after I format my pc and re-install the windows, and I re-install the CP210x for axonII. But my device manager the COM port shown code 10 of the CP210x device.
How can I fix it ? Thanks !
« Last Edit: March 15, 2012, 06:29:03 AM by strif »

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #1 on: March 01, 2012, 04:51:23 AM »
1 month ago, I had use the Ro0110_ex_Fboot for ‘burn' the C code inside my Axon II, for test my circuit, and now I done my hardware parts of the robot arm. But I fail to connect my Axon II with my PC, as usually I design my program in Project, and generate hex code on AVR4, but when I using Fboot.exe , I fail to link Axon II. Then I tried find out my com port in device manager but It didn't show, then I add hardware by manually, add in the silicon lab USB to UART bridge in Device Manager. But It shown the Code 10. This device cannot start. The Next step I uninstall all the driver and re install. Plug in my Axon II without power on, my windows didn't pop up the msg " found a new hardware " , so I manually add hardware again, but still occur the code 10 error. I have repeat few times and on different desktop PC. ( without plug in the Axon, Install the Silicon Lab driver 6.5, and plug in Axon without power up ) . Problem still remain as code 10.

Am I missed any step , or my Axon silicon lab chip had been burned ? I am urgent to write my c code inside Axon and run up my hardware .

Thanks for Help .

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #2 on: March 01, 2012, 05:06:53 AM »
This might help --> How To Fix Code 10 Errors
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #3 on: March 01, 2012, 07:10:06 AM »
Thanks for newInRobotics,

I tried remove Silicon Lab driver and uninstall all the usb host controller, root hub and etc.
and restart pc and re-install the silicon lab ver.6.5. Plug in Axon II without power on, my pc still can't detect a new hardware, I tried to open on axon II , result still remain nothing new device was detected.
 

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #4 on: March 01, 2012, 07:25:44 AM »
If some problem with my Silicon Lab chip, means that I can't use the USB anymore ? Can I use AVRISP for the programming code ?  : (

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #5 on: March 03, 2012, 10:11:32 AM »
Anyone can help ? Thanks .

urgent

Offline definitionofis

  • Jr. Member
  • **
  • Posts: 41
  • Helpful? 1
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #6 on: March 03, 2012, 10:56:18 AM »
I don't know much about this topic, but since nobody can help,
I have an idea to narrow down the problem.

Download Linux to a CD and boot and run Linux from the CD and see if it recognizes the USB device.
Then you might at least know the problem is MSwindows and not the Axon board.
It won't change any of your MSwindows installation as long as you select Run from CD; ie. you do not have to install Linux.

In Linux you can run this command in a xterm window:
lsusb -v | less

It will give a long list of detected USB device details which you can page up and down through.

How to run xterm:  Press that goofy three-dots-black-and-white-top-left-corner icon and type xterm to search for the xterm program and run it. (PS: I hate icons as a method of helping somebody).


www.ubuntu.com/download

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #7 on: March 08, 2012, 07:28:13 AM »
1) does the CP2102 USB chip overheat when plugged into USB?

2) when using a multimeter, do you detect 3.3V on the 3.3V output pin?

3) try on a different computer

4) does the USB port show up in Device Manager when plugging the Axon in?

5) which Windows version are you using?

6) did you ever plug anything at all into the 3.3V output pin?


And yeap, you can still program your Axon using an ISP hardware programmer. It will delete the bootloader, but you can always put it back later if you wanted (easy to do).


ps - Sorry for the delayed reply . . . a close friend of mine came to visit me, so we spent 5 days on an island with no internet access . . .

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #8 on: March 08, 2012, 09:34:31 AM »
1) does the CP2102 USB chip overheat when plugged into USB?
   Nope, I didn't feel any heat from the chip


2) when using a multimeter, do you detect 3.3V on the 3.3V output pin?
   Yes, both of them , but I didn't get potential different at pin I^2C ( 3rd pin beside 3.3v ) 

3) try on a different computer
   Yes , tried on 3 different computer ( Win Vista 32bit , Win XP )

4) does the USB port show up in Device Manager when plugging the Axon in?
   Nope , nothing changing ( installed driver or non-install driver )

5) which Windows version are you using?
    Win Vista 32bit

6) did you ever plug anything at all into the 3.3V output pin?
    Never use the 3.3v output pin


And yeap, you can still program your Axon using an ISP hardware programmer. It will delete the bootloader, but you can always put it back later if you wanted (easy to do).

I had purchaser the Atmel AVRISP device, It will deliver on 12 March , When I plug in the device to my Axon II , It will auto deleted the bootloader ? If I using Project_Designer setup my program and load into AVR studio 4 , I have to load in the bootloader into Axon II or I can direct load the .hex file from my AVR studio 4 into Axon II and run the program code ?

Thanks Admin

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #9 on: March 08, 2012, 09:36:59 AM »
Dear definitionofis,

I had install Ubuntu into my D: drive , It is cool to use .
I have key in the Iusb -v | less code and it show a lot of device code in the xterm , but I dunno how to read out which device is Axon II , I only saw 2 usb device is plug in , which is my WiFi adapter and mouse ( show name in the Xterm usb list ) .

Thanks for help !

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #10 on: March 08, 2012, 07:23:43 PM »
Do you have a fine tipped soldering iron? There is one more thing you can try. I'm thinking it's possible that the USB connector became slightly disconnected and that re-melting the solder on the 5 USB pins might fix it. But if you do this, be careful not to create solder bridges between the pins.

I had purchaser the Atmel AVRISP device, It will deliver on 12 March , When I plug in the device to my Axon II , It will auto deleted the bootloader ? If I using Project_Designer setup my program and load into AVR studio 4 , I have to load in the bootloader into Axon II or I can direct load the .hex file from my AVR studio 4 into Axon II and run the program code ?
The AVRISP will let you direct load the .hex so you will no longer need the bootloader. The bootloader program is also a .hex, so you can always load it back later if you want.

Having USB working is very useful for debugging your programs later on, so it's still worth fixing.

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #11 on: March 09, 2012, 09:02:14 AM »
Dear Admin,

I didn't have good soldiering skill and didn't have the fine type solder iron   :'(
I try load my c code into axon and run it .
Thanks for your help !


PS: May I send it to you after this project, help me diagnostic it ? Thanks

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #12 on: March 09, 2012, 09:20:14 AM »
Quote
PS: May I send it to you after this project, help me diagnostic it ?
Maybe. Let me know when you're done and we can talk about it.

At the moment I'm living in Asia until this summer, so won't be able to diagnose/repair anything unless you pay for shipping costs to here :P

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #13 on: March 09, 2012, 09:35:04 AM »
Dear Admin,

I am from Malaysia , Asia too  :D

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #14 on: March 09, 2012, 10:18:03 AM »
I am from Malaysia , Asia too  :D
Perfect! I'm in Thailand. :)

You have until mid April to get back to me on it, so no rush. When you're ready, PM me for detailed mailing instructions. Hopefully shipping costs are low given how close you are!

I have a good soldering iron here with me, but most of my equipment is back in the US. I can't promise I'll be able to fix it, but I will do my best.

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #15 on: March 09, 2012, 10:23:39 AM »
Dear Admin,

Thanks a lot for spend your time on my axon board  ;D ;D
we discuss it later on .

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #16 on: March 12, 2012, 12:02:16 AM »
Dear Admin,

I received my AVRISP mkII today and Can communication with AxonII and program .hex into flash with AVR Studio4.

I have a question about I wanna write my own C code in the AVR Studio4 without using the ProjectDesigner , which .c .h file I have to include in my new project file for full function the Axon II I/O pin, timer, 5volt output and each ?

Thanks

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #17 on: March 12, 2012, 03:38:29 AM »
Project Designer does all the low-level code for you, and so is required with WebbotLib v2.

You only need to use Project Designer once, and you won't need it again unless you make a major hardware change. You can hand modify the .h files later, although they will get overwritten if you use PD again.

If you wish to hand write all of your code without ever using PD, you will need to use WebbotLib v1. The manual will explain what to do. You will have to write your own .h and .c files.

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: error code 10 of COM port of the CP210x USB to UART Bridge
« Reply #18 on: March 15, 2012, 01:52:20 AM »
Yes, I am stupid in coding.

This is the pin_out from Project_Designer and I have to use those name as my main loop?
Driver_code_part_2.cpp
Code: [Select]
#include "hardware.h"

// Initialise the hardware
void appInitHardware(void) {
initHardware();
}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

// -------- Start Switch/Button-------
// Switch/Button - see switch.h

// To test if it is pressed then
if(button.pressed()){
// pressed
}

// To test if it is released then
if(button.released()){
// released
}
// -------- End   Switch/Button-------

// -------- Start Marquee-------
{
// A marquee is a 'Stream' so can use the print calls -
// but need to end with '\n' to start scrolling

// If the endDelay is non-zero then the marquee will scroll
// forever or until you call: marquee.stop();

// If the endDelay is zero then the marquee will stop once
// the entire line has been shown ('one-shot' mode)

// In 'one-shot' mode then you may want to make sure that
// a previous line has finished before you display a second line.
// This can be done as follows:-
marquee.setEndDelay(0); // Make sure we are in one-shot mode
if(marquee.isActive()==FALSE){
     if(loopCount==1){
      marquee.print_P(PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"));
     }else{
marquee.print_P(PSTR("Loop="));
marquee.print(loopCount);
marquee.println();
     }
}

}
// -------- End   Marquee-------

// -------- Start Analogue Output - PWM-------
// The current duty cycle, ie the % time it is high, can be read as follows:-
PERCENTAGE PWMduty = PWM.getPercent();

// Or it can be set to 75% using
PWMduty = 75;
PWM.setPercent(PWMduty);
// -------- End   Analogue Output - PWM-------




// -------- Start Digital Output-------
// Set the pin high
D_OUTPUT_MA_1.high();
// Set the pin low
D_OUTPUT_MA_1.low();
// Toggle the pin ie high->low, or low->high
D_OUTPUT_MA_1.toggle();
// Output a high pulse of 1000us
D_OUTPUT_MA_1.pulseOut(1000,TRUE);
// -------- End   Digital Output-------


// -------- Start Digital Output-------
// Set the pin high
D_OUTPUT_MA_2.high();
// Set the pin low
D_OUTPUT_MA_2.low();
// Toggle the pin ie high->low, or low->high
D_OUTPUT_MA_2.toggle();
// Output a high pulse of 1000us
D_OUTPUT_MA_2.pulseOut(1000,TRUE);
// -------- End   Digital Output-------


// -------- Start Digital Output-------
// Set the pin high
D_OUTPUT_MB_1.high();
// Set the pin low
D_OUTPUT_MB_1.low();
// Toggle the pin ie high->low, or low->high
D_OUTPUT_MB_1.toggle();
// Output a high pulse of 1000us
D_OUTPUT_MB_1.pulseOut(1000,TRUE);
// -------- End   Digital Output-------


// -------- Start Digital Output-------
// Set the pin high
D_OUTPUT_MB_2.high();
// Set the pin low
D_OUTPUT_MB_2.low();
// Toggle the pin ie high->low, or low->high
D_OUTPUT_MB_2.toggle();
// Output a high pulse of 1000us
D_OUTPUT_MB_2.pulseOut(1000,TRUE);
// -------- End   Digital Output-------



// -------- Start Digital Input-------
// Read the Digital Input (see iopin.h) and do something
if(D_INPUT_LM1_1.isHigh()){
// The pin is high
}else{
// The pin is low
}
// Measure the duration of a high pulse on an input pin
TICK_COUNT pulse = D_INPUT_LM1_1.pulseIn(TRUE);
cout << "Len=" << pulse << "\n";
// -------- End   Digital Input-------



// -------- Start Digital Input-------
// Read the Digital Input (see iopin.h) and do something
if(D_INPUT_LM1_2.isHigh()){
// The pin is high
}else{
// The pin is low
}
// Measure the duration of a high pulse on an input pin
TICK_COUNT pulse = D_INPUT_LM1_2.pulseIn(TRUE);
cout << "Len=" << pulse << "\n";
// -------- End   Digital Input-------



// -------- Start Digital Input-------
// Read the Digital Input (see iopin.h) and do something
if(D_INPUT_LM2_1.isHigh()){
// The pin is high
}else{
// The pin is low
}
// Measure the duration of a high pulse on an input pin
TICK_COUNT pulse = D_INPUT_LM2_1.pulseIn(TRUE);
cout << "Len=" << pulse << "\n";
// -------- End   Digital Input-------



// -------- Start Digital Input-------
// Read the Digital Input (see iopin.h) and do something
if(D_INPUT_LM2_2.isHigh()){
// The pin is high
}else{
// The pin is low
}
// Measure the duration of a high pulse on an input pin
TICK_COUNT pulse = D_INPUT_LM2_2.pulseIn(TRUE);
cout << "Len=" << pulse << "\n";
// -------- End   Digital Input-------



// -------- Start Digital Input-------
// Read the Digital Input (see iopin.h) and do something
if(D_INPUT_LMC_1.isHigh()){
// The pin is high
}else{
// The pin is low
}
// Measure the duration of a high pulse on an input pin
TICK_COUNT pulse = D_INPUT_LMC_1.pulseIn(TRUE);
cout << "Len=" << pulse << "\n";
// -------- End   Digital Input-------

return 0;
}


And this is the internal clock from AxonII , how I call it out as
getclock = clock;
if getclock = 5000; // as 5sec  //
( )
else ...
gen_clock.c
Code: [Select]
// Its a component of the library
#define BUILDING_LIBRARY

// Include hardware info for this device
#include <avr/io.h>



#include <libdefs.h>
#include <clock.h>


#define CLOCK_PRESCALE 8
#define CLOCK_TOP 64000


// #define msPerTop (CLOCK_TOP*1000U*CLOCK_PRESCALE/F_CPU)
#define msPerTop 32

#define usPerTop (msPerTop * 1000U)  // convert to uS
static volatile TICK_COUNT wholeTicks;


#define CLOCK_INT_PENDING bit_is_set(TIFR1,OCF1A)
#define CLOCK_INT_CLEAR sbi(TIFR1,OCF1A)

#define CLOCK_INT_ENABLE sbi(TIMSK1,OCIE1A)
#define CLOCK_INT_DISABLE cbi(TIMSK1,OCIE1A)

#define CLOCK_TOP_REG OCR1A
#include <errors.h>
#define STATUS_LED_PORT  PORTC
#define STATUS_LED_INPUT PINC
#define STATUS_LED_DDR   DDRC
#define STATUS_LED_PIN   PC1
static uint8_t counter;


void clockGetSnapshot(TIMER_SNAPSHOT* snapshot){
// Clock timer uses TIMER_MODE_CTC_OCR which generate compare interrupts on channel A
CRITICAL_SECTION{
// get the current ticks from the timer
uint16_t tcnt = TCNT1;
// get the number of whole ticks
snapshot->whole  = wholeTicks;
// get the current ticks again
snapshot->part   = TCNT1;
// If the second reading of tcnt has gone down then there must have been an overflow
// since reading the 'rtn' value. Or there may be a pending interrupt which may be
// because interrupts are currently turned off. In either case increment the 'rtn' value
// as if the interrupt has happened
if(snapshot->part < tcnt || CLOCK_INT_PENDING ){
snapshot->whole += usPerTop;
// get the current ticks again
snapshot->part = TCNT1;
}
}
}

TICK_COUNT clockSnapshotToTicks(const TIMER_SNAPSHOT* snapshot){
TICK_COUNT rtn = snapshot->whole;

// top = usPerTop
// part     x
TICK_COUNT frac  = snapshot->part;
frac *= usPerTop;
frac /= CLOCK_TOP;

rtn += frac;

return rtn;
}

// Get the current clock time in uS
TICK_COUNT clockGetus(void){
TIMER_SNAPSHOT snapshot;
clockGetSnapshot(&snapshot);

return clockSnapshotToTicks(&snapshot);
}

// Initialise the clock timer and turn it on
void __clockInit(void){
// Set interrupt pending = false
CLOCK_INT_CLEAR;

// Enable interrupts
CLOCK_INT_ENABLE;
}

// ISR for clock overflow. Occurs every msPerTop
ISR(TIMER1_COMPA_vect) {
wholeTicks += usPerTop;


// Flash the status led if there is an error
ERROR* err = &__error;
if(err->errorCode && bit_is_set(STATUS_LED_DDR,STATUS_LED_PIN)){
// There is an error and status led pin is an output

// Decrement any counter
if(counter){
counter--;
}
if(counter==0){
// Its time to do something
if(err->remaining==0){
err->remaining = ABS(err->errorCode);
}

uint8_t delay = (err->errorCode < 0 ) ? 250/msPerTop : 500/msPerTop;
if(err->phase){
// turn led off
if(-- err->remaining == 0){
delay = 2000/msPerTop;
}
}else{
// turn led on
}
err->phase = !err->phase;
counter = delay;
// toggle the LED
sbi(STATUS_LED_INPUT,STATUS_LED_PIN);
}
}

}

I can add in / remove the Pin from here without going back to first step at Project_Designer?
opt_DeviceName.c
Code: [Select]
#include "../hardware.h"
static const char PROGMEM name_button[] = "button";
static const char PROGMEM name_uart1[] = "uart1";
static const char PROGMEM name_led_display[] = "led_display";
static const char PROGMEM name_marquee[] = "marquee";
static const char PROGMEM name_PWM[] = "PWM";
static const char PROGMEM name_D_OUTPUT_MA_1[] = "D_OUTPUT_MA_1";
static const char PROGMEM name_D_OUTPUT_MA_2[] = "D_OUTPUT_MA_2";
static const char PROGMEM name_D_OUTPUT_MB_1[] = "D_OUTPUT_MB_1";
static const char PROGMEM name_D_OUTPUT_MB_2[] = "D_OUTPUT_MB_2";
static const char PROGMEM name_D_INPUT_LM1_1[] = "D_INPUT_LM1_1";
static const char PROGMEM name_D_INPUT_LM1_2[] = "D_INPUT_LM1_2";
static const char PROGMEM name_D_INPUT_LM2_1[] = "D_INPUT_LM2_1";
static const char PROGMEM name_D_INPUT_LM2_2[] = "D_INPUT_LM2_2";
static const char PROGMEM name_D_INPUT_LMC_1[] = "D_INPUT_LMC_1";
static const char PROGMEM unknown[] = "?";

#define NUM_DEVICES 14
static const void* PROGMEM tbl[]={
&_button_, name_button,
&__C_uart1, name_uart1,
&_led_display_, name_led_display,
&_marquee_, name_marquee,
_PWM_, name_PWM,
_D_OUTPUT_MA_1_, name_D_OUTPUT_MA_1,
_D_OUTPUT_MA_2_, name_D_OUTPUT_MA_2,
_D_OUTPUT_MB_1_, name_D_OUTPUT_MB_1,
_D_OUTPUT_MB_2_, name_D_OUTPUT_MB_2,
_D_INPUT_LM1_1_, name_D_INPUT_LM1_1,
_D_INPUT_LM1_2_, name_D_INPUT_LM1_2,
_D_INPUT_LM2_1_, name_D_INPUT_LM2_1,
_D_INPUT_LM2_2_, name_D_INPUT_LM2_2,
_D_INPUT_LMC_1_, name_D_INPUT_LMC_1
};

const char* getDeviceName(const void* device){
const char* rtn = unknown;
for(int i=0 ; i<NUM_DEVICES*2; i+=2){
const void* addr = (const void*)pgm_read_word(&tbl[i]);
if( addr == device){
rtn = (const void*)pgm_read_word(&tbl[i+1]);
}
}
return rtn;
}


My design concept is
initial = D_OUTPUT_MA_1= D_OUTPUT_MA_2 = D_OUTPUT_MB_1 = D_OUTPUT_MB_2 = 0;

if( LM1_1=1; LM1_2=0)
{
do something
}
else if ( LM1_1=0;LM1_2=0)
{
do something
}
else if ( LM1_1=0;LM1_2=1)
{
do something
}
// LM1_1=LM1_2=1 won't happen //

When ( .... )
{
do something
}

those step including a counter as my progress time



Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: request suggestion in basic c code [ post #18]
« Reply #19 on: March 18, 2012, 08:15:40 AM »
hmmmm I don't quite understand your question/problem. What isn't working?

Also, why not use WebbotLib v2? It writes all the code for you  :P

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: request suggestion in basic c code [ post #18]
« Reply #20 on: March 18, 2012, 12:24:19 PM »
hmmmm I don't quite understand your question/problem. What isn't working?

Also, why not use WebbotLib v2? It writes all the code for you  :P

Dear Admin,

I not sure that I had been set it as WebbotLib v2.08 or remain the V1.35

I set those I/O pin at Project_Designer and wanna combine them base on my logic/program.
I) How should I set those I/O pin follow the process that I want ?
II) How I set a Timer/Counter inside Project_Design so that I can program process by following the timer
     As :  while ( Timer_1 = 10sec )  then.....

III) Any tutorial about program my project process in Project_Designer ?

Thanks !

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: request suggestion in basic c code [ post #18]
« Reply #21 on: March 18, 2012, 11:33:25 PM »
I read the WebbortLib_version_2.08 and found the function clockGetus

I wrote a code as :-

if(FLAG_GRIPPER=0)
{
   TICK_COUNT start_MoveLeft_1 clockGetus();
         
   DRIVER_SPEED speed=DRIVER_SPEED_MIN;   // Can I set the driver_speed by this code ?
         
   TICK_COUNT end_MoveLeft_1 clock Getus();
   TICK_COUNT duration=3000000;  // 3sec
         
   FLAG_GRIPPER=1;    //<== my FLAG_GRIPPER will set to 1, after done the TICK_COUNT duration or Direct set to 1?
}

else return;

I have to add on the clockHasElapsed function if I wanna the FLAG_GRIPPER set to 1 after 3 sec ?
as:-
            TICK_COUNT start = clockGetus();  // Get the start time
            TICK_COUNT wait = 3000000;  //  3sec
            while(clockHasElapsed(start, wait)==TRUE)
            {
                      FLAG_GRIPPER=1;
            }


Thanks

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: request suggestion in basic c code [ post #18]
« Reply #22 on: March 22, 2012, 06:19:17 AM »
I not sure that I had been set it as WebbotLib v2.08 or remain the V1.35
WebbotLib v2 will write most of the code for you, and is much easier to use. But you must use Project Designer to do it.

WebbotLib v1 requires you to write more of the code and has no GUI to help you - you must read the manual.

When you download the library, it'll have the version number written on it. Which WebbotLib version are you using?

Once I know what version you are using, I can then help with your other questions :)

But, my #1 recommendation is to use v2 and follow the instructions in the video.


As for the timer . . . this is how to do it.

Code: [Select]
TICK_COUNT start_time Getus();
TICK_COUNT duration=3000000;  // 3sec
TICK_COUNT elapsed=0;

while(1)
{
elapsed = Getus() - start_time;//check the time passed

if(elapsed>duration)//if the time passed is greater than 3 seconds
            {
            start_time = Getus();//reset the clock

            do_something();//run your code
            }
}

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: request suggestion in basic c code [ post #18]
« Reply #23 on: March 22, 2012, 05:32:47 PM »
Thanks Admin !  I get the idea of the code !

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: request suggestion in basic c code [ post #18]
« Reply #24 on: March 26, 2012, 02:47:01 AM »
When I Complite my code

It come out
"
/usr/bin/sh:g++: command not found
make. ***[main.o] Error 127
Build failed with 1 errors and 0 warnings.. "

I can build active config.
"

Device: atmega640

Program:   16486 bytes (25.2% Full)
(.text + .data + .bootloader)

Data:        480 bytes (5.9% Full)
(.data + .bss + .noinit)


Build succeeded with 0 Warnings...
"


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: request suggestion in basic c code [ post #18]
« Reply #25 on: March 26, 2012, 05:30:38 AM »
In AVR Studio, tell it to Clean first, then rebuild. That *might* work.

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: request suggestion in basic c code [ post #18]
« Reply #26 on: April 02, 2012, 11:08:58 PM »
 :-\

I tried " Clear current configuration " and compile

but It remain this

Code: [Select]
g++  -g -Wall -DF_CPU=16000000 -mmcu=atmega640 -gdwarf-2 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields -I"../../../../AxonII_2/webbotavrclib-2.08"  -MD -MP -MT Code_2_main.o -MF dep/Code_2_main.o.d -fno-threadsafe-statics  -c -o Code_2_
main.o Code_2_main.cpp

/usr/bin/sh: g++: command not found
make: *** [Code_2_main.o] Error 127
Build failed with 1 errors and 0 warnings...



Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: request suggestion in basic c code [ post #18]
« Reply #27 on: April 02, 2012, 11:56:40 PM »
Are you sure you installed gcc, and that it installed properly?

Are there spaces in the pathname for where you installed it?


Or did you install the latest tool set for AVR Studio? (don't do this; it messes up the path names and then you'll have to manually fix them)

Offline strifTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Re: request suggestion in basic c code [ post #18]
« Reply #28 on: April 03, 2012, 01:02:58 AM »

Are you sure you installed gcc, and that it installed properly?

Are there spaces in the pathname for where you installed it?


Or did you install the latest tool set for AVR Studio? (don't do this; it messes up the path names and then you'll have to manually fix them)

Dear Admin,

I not sure and understand about gcc,
the project working well before I wrote in my code and save as new file inside the project folder as code_2_main.cpp


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: request suggestion in basic c code [ post #18]
« Reply #29 on: April 03, 2012, 01:46:51 AM »
gcc is the compiler. Everything will work fine until you need to compile your code into a .hex file.

Did you install WinAVR?

 


Get Your Ad Here

data_list