piątek, 13 listopada 2015

IBT-3 H-bridge module with arduino


Back after some time with good news :)


For my personal project I was looking for H-bridge module. There is always option DIY or BIY....

Anyway, there is very nice article about older module IBT-2 but probably there is no article about IBT-3 ...

This is picture of IBT-3 module which come to me from ebay (id: good4deal999).


It has few connectors. IN1, IN2, GND, PWR -/+ and MOTOR (power output).

From description:
- 50A current limit,
- 5V up to 15V (tested by me on 5S life accu, works, no issues with 120Watt/12V rc tire truer engine),
- max 99% PWM.

Caution: please remember that this module can't accept 100% PWM pulse width. Can't use 255 value in analogWrite() function. DC engine will cogg!!!

In my case, when I drive on arduino like UNO shield, 99% gives value 252.45 from 255 (analogWrite(PIN, value)), but I tested 254, module probably works on limit now.

In prototype device which is not published ;) max value of PWM is 252, will test it on 254 to see which element get hot ;)

 Some wires mess:









Movie:

 

Arduino sample code:

// IBT-3 H-bridge module test
// m.abramowicz@abram.pl
// 2015-11-13

/*
 * simple test code which will rotate CCW and CW small DC engine using PWM
 * from ebay page there is info that this module needs max 99% for PWM, can't use 100% :(
 * if 255 is max value for analogWrite, then 99% is about 252.45 -> 252 max!
 * if value 255 is set, then DC engine cogs ...
 * max tested is 254 without cogging
 */

// define pins
// arduino 5 -> IN1
#define PIN_CW 5
// arduino 6 -> IN2
#define PIN_CCW 6

// max tested was 254
#define MAX 252

void setup() {
  pinMode(PIN_CW, OUTPUT);
  pinMode(PIN_CCW, OUTPUT);
  // set h-bridge pins to 0
  digitalWrite(PIN_CW, LOW);
  digitalWrite(PIN_CCW, LOW);
  delay(300);
}

void loop() {
  // put your main code here, to run repeatedly:

  // PIN_CCW set to LOW;
  digitalWrite(PIN_CCW, LOW);
  //start CW
  for (int fadeValue = 0 ; fadeValue <= MAX; fadeValue += 2) {
    analogWrite(PIN_CW,fadeValue);
    delay(10);
  }
  delay(1500);
  // stop
  for (int fadeValue = MAX ; fadeValue >= 0; fadeValue -= 2) {
    analogWrite(PIN_CW,fadeValue);
    delay(10);
  }
  digitalWrite(PIN_CW, LOW);

  //start CCW
  for (int fadeValue = 0 ; fadeValue <= MAX; fadeValue += 2) {
    analogWrite(PIN_CCW,fadeValue);
    delay(10);
  }
  delay(1500);
  // stop
  for (int fadeValue = MAX ; fadeValue >= 0; fadeValue -= 2) {
    analogWrite(PIN_CCW,fadeValue);
    delay(10);
  }
 
}

I can say, for that money what I paid, there is almost no option to do it better at home with my skills ;) Prepare project, count some values ... I said no, not for 10$ ... I'm not electronic kung fu panda!


sobota, 14 czerwca 2014

OpenLDAP backup and restore

I'm going to change some schema and data in my ldap ;)

But 1st thing is how to restore ldap from ldiff file when something will go bad ...

1st is backup
2nd is store backup on other host/disk/whatever, it can be printed each time ;)
3rd is how to restore it when disaster come true ...

1st) backup like this? hm ... put it to cron ;)

[root@samba64 tmp]# slapcat  -o ldif-wrap=no > slapcat-o-ldif-wrap-n.ldiff


2nd) when file is created send it somewhere ;)

3rd) restore from ldiff file, please remember about correct schema files,
if there is something 'strange' (my setup has some tweaks for Postfix) then also backup schema files :P just in case :P ;-) 

how to restore it?

- shut down ldap server,
- remove broken files, in my case just clean directory /var/lib/openldap-data or rename it,
-  change directory to /var/lib/openldap-data,
- do command: slapadd -v -l ~/LDAP/slapcat-o-ldif-wrap-n.ldiff,
- chown slapd:slapd files in /var/lib/openldap-data (beware, it is my PLD Linux ;) ),
- start ldap,
- check it. something like this:

ldapsearch  -b "ou=Users,dc=XXXX,dc=pl" -D "cn=Manager,dc=XXXX,dc=pl" \
        -w MyPassword -x -v \
        -h 127.0.0.1\
        '(&(objectClass=PostfixUser)(accountStatus=active))' mail

Uff done ...

Restore procedure looks like "IT WORKS!"

:-)

Next step is add and change some data in my secret schema ;) then do some tricks with ldiff file ...


środa, 14 maja 2014

Sun ultra 10


Back to home :)
Sun ultra 10, 450mhz, 512 mb, 2x hdd ata 20gb

Power of SQL

And again ... I've discovered power of SQL in PostgreSQL db ...

begin;

insert into przetargi_zalaczniki
(
    przetarg_id,
    zalacznik,
    plik,
    createdby,
    datapublikacji
 )
select 991, zalacznik, plik, createdby, '2014-05-14 14:55:05'
from przetargi_zalaczniki
where przetarg_id=970;

commit;