go away spammer

Author Topic: Webbotlib and servo init problem  (Read 2724 times)

0 Members and 1 Guest are viewing this topic.

Offline mikevlzTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Webbotlib and servo init problem
« on: August 09, 2013, 08:58:31 AM »
I have a problem in my project. It is a hexapod with 3DOF per leg, so it has 18 servos. I try to use software servo driver in webbotlib. The problem is:
- when i upload the code via bootloader, everything works well untill MCU is reset. I don't mean, that it resets on it's own.
- when i power MCU on or reset it after loading software via bootloader, servos don't move. appControl loop works fine, because it send data via UART as it should.

MCU: ATMega32@8MHz
UART: Bluetooth module@9600bps
Servos: SG90
Power supplies: separate. servos have their own supply(Li-Ion).
bootloader: AVRUBD.
Webbotlib: 2.08

I tried it on the basic example code, produced by Project Designer.

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Webbotlib and servo init problem
« Reply #1 on: August 10, 2013, 11:31:06 AM »
Is the power to the servos being toggled when you reset the MCU?  Does your setup work if you toggle servo power after resetting the MCU?

Obviously, you shouldn't have this issue... Just throwing the above question so as to provide more info for debugging :)
I

Offline mikevlzTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Webbotlib and servo init problem
« Reply #2 on: August 10, 2013, 11:44:23 AM »
Yes, i tried to power cycle servos, no effect.
The board is self made. other code(not webbotlib) works with servos in any circumstansies. But this code has other errors, so i decided to try webbotlib.
MCU and servos have common ground, power supplies are good enough to make both MCU and servos work.

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Webbotlib and servo init problem
« Reply #3 on: August 11, 2013, 02:21:29 PM »
Another shot in the dark: have you disconnected the programmer entirely from the board?

(I vaguely recall having something like this happen in the past with an Axon, but I can't recall any details :/ )
I

Offline mikevlzTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Webbotlib and servo init problem
« Reply #4 on: August 12, 2013, 12:20:23 AM »
There is no programmer. I program the MCU via bootloader. This means that i need to setup UART between MCU and computer, start a program, which talks to bootloader, reset MCU. When controller starts up, it has an address of a bootloader sector as an startup address. If bootloader procedure gets some code from computer, it will wait for a program and flash it into program memory. After flashing(or waiting for some seconds for code) MCU starts working as if there were no bootloader - it goes to 0x0000 and works on user's program.
So my setup is:
a board itself with ATMega32
BT-module connected to MCU
The only things i connect/disconnect are batteries and servos.

Offline mikevlzTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Webbotlib and servo init problem
« Reply #5 on: August 13, 2013, 04:48:39 AM »
Just a followup, I think, you would like to know that.
I have checked the following:
1. Create totally new project with my board and a single servo. Nothing changed. It would start moving servo only after bootloader flashed program. Servo doesn't move after reset.
2. Change fuses so, that bootloader doesn't start(boot vector fuse bit). After flashing only this fuses - everything works fine. I can reset and power-cycle my board in any way. Servos keep initializing and keep moving.
So I have some questions:
1. How does webbotlib interfere with AVRUB? I believe it is a bootloader fault in this case. But I had an experiment with constantly printing "hello world" via UART and I saw it in my terminal program. MCU didn't reset after bootloader gave up, because it would start bootloader again, which sends "connect char" via UART. So if I pressed reset, I saw multiple connect chars(bootloader works) and after that(10 tries to connect and get firmware) I saw "hello world" printed in a loop. But servos didn't initialize properly.
2. Is there any configurable bootloader, that is known to work good(not interfere with webbotlib), so that I used it for flashing? I'm too lazy to connect my programmer to the board, have this wires across the table, this makes me nervous ;)

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Webbotlib and servo init problem
« Reply #6 on: August 13, 2013, 12:24:29 PM »
Replied to your email as well.
Think the bootloader is probably leaving someprocessor registers in a non-default power on state.
ie power on with the fuses turning off the bootloader then everything is fine.
have the bootloader fuses enabled then it enters the bootloader, times out, runs your program but the registers are not in the default state as defined in avr data sheets.

So answer is: get the bootloader people to change their code to restore the machine state after timing out or ask me to add code to every single program that is generated by WebbotLib to reset the machine to its default state (thereby bloating the code for every program!). Oh - and I ain't gonna do point 2 ;-)

User programs should always be totally oblivious to the bootloader being present - let alone which bootloader it is. So if the bootloader is messing stuff up - then the bootloader needs fixing - not WebbotLib.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline mikevlzTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Webbotlib and servo init problem
« Reply #7 on: August 13, 2013, 12:52:57 PM »
I'll try different settings of current bootloader and search for alternative one, if nothing helps. Or I'll add some code to the current bootloader, as it is open source one, to reset after timing out as if there was something downloaded and flashed.
Thanks for trying to help, guys!

Offline mikevlzTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Webbotlib and servo init problem
« Reply #8 on: August 13, 2013, 01:08:25 PM »
Seems like I've found the problem. It uses TIMER1 to countdown the connect delay. The only place it shuts down TIMER1 is after successful connect. I'll try to move this to the quit() function in bootloader. I think that will be enough.

UPDATE:
That worked.
For those who want to use AVR UB and webbotlib, they should insert the following:
Code: [Select]
  TCCR1B = 0;                   //close timer1
into void quit()
Otherwise bootloader wont unconfigure TIMER1 and webbotlib will not start servos, if they are software PWM and work with TIMER1.
The problem is solved.
« Last Edit: August 13, 2013, 01:18:54 PM by mikevlz »

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
    • Index of Oddities
Re: Webbotlib and servo init problem
« Reply #9 on: August 16, 2013, 06:23:57 PM »
Good to hear! Thanks for posting the solution/explanation, as well.
I

 


Get Your Ad Here

data_list