BIPEDU

my ideas in action

Firefox and Backspace and AutoScroll

From time to time I notice that Firefox change some settings after an upgrade. Maybe there are bugs or simple Firefox guys decide that we simple users are stupid and we do not need certain features.

The ones that I use the most are the middle-mouse/wheel autoscroll and backspace to go to the previous page.

So in case they are missing from your Firefox then you can activate them from : about:config and then setting true for autoscrollFFautoscroll

 

 

and setting 0 for backspace_action:

FFbackspace

Advertisements

samba server on tinycore linux – howto

Simple setup for samba server on Tinycore linux server. Many tutorials are available on internet but mine is tested and it working as I want.

First install samba package on Tinycore linux.

from “tc” user start tce-ab

Then edit the smb.conf file from /usr/local/etc/samba/smb.conf.
Inside add something like this:

[global]
workgroup = WORKGROUP
netbios name = box
security = user

[atom_1t]
comment = Data
path = /mnt/sda1
read only = no
guest ok = no

Explanations:

security = user
this will create a share that is based on user/password

netbios name = box
this will be the name of your server ( alias to avoid tiping the IP address)

read only = no
to have write access

guest ok = no
no allow of guest users ( no anonymous connections)
Then as root you run this command

 smbpasswd -a <tinycore user>

then type the samba password for that user. You will use this password from the client machine when you will connect to the samba share
then save the samba config files to make the changes persistent after reboot.

add in /opt/.filetool.lst

usr/local/etc/samba/smb.conf            <-- this contain samba setup
usr/local/etc/samba/private/passdb.tdb  <-- this contain your password

then backup with “backup”
and then restart the server

Next go at the client machine and in filemanager type:
smb://box/
and you should get a popup window asking for user and password. Put the user and that password you set on samba.

easy backup system with rsync – like Time Machine

Backup systems are good for recovering in case of accidental  lost data. But a more useful feature is the incremental backup where you have access to various snapshots in time like the Time Machine on Apple is doing. To do this in Linux (or any Unix  or alike ) systems is actually very easy.

For example we make a backup every day ( or every internal you want) . We need that  the amount of data transferred is small and not big. Imagine transferring few TB every day ! in case our important data is changing a little bit then we will backup only the modified parts. For this Rsync is the best tool. Everybody knows that. But there is a problem. How can we keep daily snapshots of the data without filling the disk ? For this we will use softlinks,  hardlinks and Rsync options.

So we have to create a script file like this:

#!/bin/bash
date=`date "+%Y-%m-%dT%H-%M-%S"`
rsync -aP --delete --log-file=/tmp/log_backup.log --exclude=lost+found --link-dest=/mnt/sdb2/Backups/current /mnt/sda1/ /mnt/sdb2/Backups/back-$date
rm -f /mnt/sdb2/Backups/current
ln -s /mnt/sdb2/Backups/back-$date /mnt/sdb2/Backups/current

So here I make first a “date” variable that will be used in the name of the backup folder to easily know when that backup/snapshot was made.

Then use the rsync with some parameters (see man rsync for more details):

-a = archive mode ( to send only changed parts)

-P = to give a progress info – (optional)

–delete = to delete the deleted files from backup in case they are removed from source

–log-file = to save the log into a file (optional)

–exclude = to exclude some folders/files from backup . This are relative to source path !!! do not use absolute path here !

–link-dest = link to the latest backup snapshot

/mnt/sda1 = source path (here I backup a whole drive)

/mnt/sdb2/Backups/back-$date  = destination folder , it will contain all the content from the source.

Then by using rm I remove the old link to the old backup ( the “current” link) and then I replace it with a new soft link to the newly created snapshot.

So now whenever I click on “current” I go in fact to the latest backup .

And because every time I make the backup the date is different the old snapshots will be kept. So for every day I will have a snapshot.

To automate this you have to create a cron job to execute the above script at the convenient time.

Example to run at 4:01AM every day:

1  4 * * * /path/to/script

Please notice that only the first time the full backup will take a long time since it will copy the full data. The second time you will run the script it will transfer only the changed files/bits.

Now on the destination folder you will see a “back-xxx” folder for every time you run the script. You can open/read the files from all this folders as it if they are completely independent files. In fact if you run df and du you will see something interesting.

For example if the backup is 600GB and the script is run every day you will see that the df will show the same 600GB used from disk space. But if you run “du -sh /* ”  you will see that each “back-xxx” folder is 600GB each. This is possible because there are only hardlinks to the same data copied. Do not worry, the disk is not full and you should trust the df results and not the du results.

user@box:/mnt/sdb2/Backups$ du  -sh ./*
623.8G    ./back-2014-02-24T17:47:12
623.8G    ./back-2014-02-24T21-46-41
623.8G    ./back-2014-02-25T17-05-02
623.8G    ./back-2014-02-25T18-45-34
0    ./current
user@box:/mnt/sdb2/Backups$ df /mnt/sdb2
Filesystem                Size      Used Available Use% Mounted on
/dev/sdb2                 2.7T    623.9G      1.9T  24% /mnt/sdb2

So the Time Machine is in fact only 3 lines of code in a script plus a cron job ! Easy and everybody can do it !

Adapt the script to your needs. Run it when you want with cron jobs.

At any point in time you can delete old backups ( for example backups older than few weeks). This can also be made with cron plus some scripts.

Tiny core linux no autologin

on Tiny core Linux distribution the tc user is automatically login at boot time.

If you want this not to happen then you have to change /opt/bootsync.sh file and to add this line :

echo “booting” > /etc/sysconfig/noautologin

and then backup with backup command. Of course all this must be run from root account.

Lab power supply with PIC microcontroller (4)

I made some small changes to the schematic. I added a zener to protect the voltage feedback into Vloop opamp.

Also I changed the way the current limitation loop take over the voltage loop. Previously I was thinking to lower the REF voltage when the ILIM is reached. I think a better way is to use 2wo diodes ( 1N4148) and a 5K resistor to make a OR function. This works better and the transition is smooth. I was looking also at similar power supply from big brands ( Agilent, HP) and they do the same thing.

The new version is 3.1:

LabPicPowerSupply_v3.1_sch ,

LabPicPowerSupply_v3.1_BOM,

LabPicPowerSupply_v3.1_pcb .

I made also an experiment to see hot the etching process works and how good are the tracks. I am disappointed somehow since I did not used a toner transfer but a simple permanent marker. The copper was partially etched on the areas where the marker was thin only.  Where it was thick it is ok. To etch I used hydrochloric acid (HCL 25%)  and oxygenated water (H2O2  10%)

I didn’t had access to a laser printer but I hope so make a full size experiment soon with toner on the real PCB.

 

 

 

Lab power supply with PIC microcontroller (3)

I have some updates regarding my project.

First of all, I have a limited time to work on this project. So it is normal to take such long time to develop it.

Second I do not want to jump too fast in “making” phase and I prefer to go slowly step by step to get a good result.

So, I was worried about the stability of my previous schematic. So after a few hours on spice simulation I understand what was the problem. Well, the main issue is that the voltage loop contained 3 low frequency poles.

One is the opamp itself that has a dominant pole at ~10Hz ( see MCP6022 spec), this cannot be avoided since any opamp will have a pole approx in this range.

The second is the output node. The main issue with this pole is that is moving with the load ( R and C) and since this is a lab power supply it will always be different.So what I decided to do is to use a small output capacitance of 1-10uF and to use a dummy load of approx 10mA. This will force the output NPN ( 2N3055) to have a minimum current even if there is no load. The main reason is that when the current is very small in the 2N3055 transistor the predriver ( BC139) will have almost no current. So the gain drops dramatically and the loop become unstable.

The other pole is at the gate of the predriver NPN . this is a “design” fault since the internal node should not affect the functionality.

So I decided to change the loop architecture and to use a intermediate amplifier with of gain of approx 5. The intermediate amplifier is made with Q4 and Q9 and the gain ratio is set by R24+R9 and R18. I chooses a gain of 5 since this gives me a opamp output voltage range between 1.3V and 4.5V for a output voltage of 0 to 21V.  Also this intermediate opamp has a high poles and do not require any compensation. Also since the gain of the amplifier set the voltage range at the output of the opamp this give me the ability to use a non Rain-to-rail output OPA. But I will keep the MCP6022 since the offset is very low and the input is rail-to-rail.

The other changes are the fact that I eliminated the resistor to SUP24V that was feeding the base of the predriver NPN.  Also I swap the opamp inputs ( intermediate amplifier has positive polarity) and I added a 100-330nF capacitor over the opamp. This compensation capacitor is necessary since I noticed that the loop may become unstable in certain conditions ( when load is changing). I need such a small value ( in the hundreds range) since the opamp will amplify the effect of this capacity  ( miller effect) and the pole generated is very low.

So the new version of the schematic is here : LabPicPowerSupply_v3_SCH

There are other minor changes :

  • removed reset PIC switch
  • removed capacitors from DAC output
  • changed the positions of some PIC  IO’s
  • added protection for the input of the opamps that measure the load current ( anti-parallel diodes)
  • added the buffer before ADC voltage measurement ( VMON). before this buffer was inside the voltage loop.
  • the ILIM protection is made by changing the voltage reference ( output of the DAC)
  • small changes in the components value
  • not use the MJ3001

I made a real test of this new architecture . I used a simple breadboard and I noticed that the stability is OK . I did not had a full test under all conditions since the 2N3055 was not on the heatsink but even like that it was capable to deliver 1A at 18V output for few seconds, this means 18W !!. I  had to stop it after few seconds since the 2N3055 became too hot.

The dummy output load I made it with the BF254B device. It was the easiest and I had laying around some devices. It can be made is many different ways but in my case I do not need accuracy.

There are some aspects that I noticed also. The predriver transistor BD139 can dissipate some power. This depend on the gain current (Hfe) of the 2N3055. My transistor had a gain of 35 at Ic=1mA so this means that trough BD139 will flow approx 30mA in the worst case. If this is happening when the output voltage is at 0V ( hard short of the lab supply terminals) then this means that the predriver will dissipate 30mA*24V =  0.72W. It may not seem too much but the datasheet show that this can bring the BD139 temperature to  ~75degC above the air temperature. If the air surrounding the device is at 30C this give a junction temperature of 100C. It is high for my taste !!! so a heatsink is mandatory !

The other issue that I noted is that 5V regulator also need a heatsink. The current consumed may reach 50mA and the power dissipated can be 1W. In this conditions LM7805 can go to 65C above the air temperature. And this is continuous and not a “error condition” like in the case of BD139. So a heatsink is really necessary. Some may argue that is not bad to use them without heatsink since this is a tolerable temperature and many Chinese manufacturers do it… well it is my design and I do not want to risk.

I made also a layout tentative.  It was not easy but at least I have a workable PCB. I still need to double-check the connection of each device to be sure that it is the correct package and the footprint is matching the actual component that I have. I hope to finish this step soon so that I can start the real manufacturing of the PCB and then component soldering.

Here are all the files for version 3  (KICAD schematic and PCB)

schematic : LabPicPowerSupply_v3_SCH

BOM list : LabPicPowerSupply_v3_BOM

PCB layout : LabPicSupply_v3_PCB

Lab power supply with PIC microcontroller (2)

So I worked more on the schematic… some changes.

Surprisingly , the hardest thing now is to search for each component and to check if it matches the footprint. This will take more days.

Regarding the case I think I will use a DVD case . the buttons are matching well the function that I want to use.

cdp-m18

The button function will be :

[-] [+] [MENU]

[down] [up] [OK]

[ON/OFF ] [ OK ]

 

 

I tried also a routing of the board… well it is hard. manual routing is a pain in the ass, . I discovered now Freerouting and I will have to play a little bit with it to see if can give good results.

 

 

Lab power supply with PIC microcontroller (1)

I just started a new project. It is a lab power supply. The main target is to do it with a microcontroler (PIC) qnd to have good enough accuracy.
My spec is 5mV per step for output voltage and 1mA per step for current. The max voltage is 20.48V and max current is 1.024A.
For this I will have a LCD screen ( 16×2 characters) and the panel will be with push burrons. I do not want to use rotary encoders.
The Lab Power Supply will use a AC-DC converter from 220V AC and will provide also some other fixed voltages like : 5V, 3.3V and maybe others (12V).
For the moment I have two old AC-DC converter from some printers (HP and Canon).
For the case I think I will use a old DVD player case since I have there all the necessary buttons and front panel.

I target to use PIC16F1789 since it is powerfull enough and has many IO pins. The ADC reading will be made with MCP3201 12bit and the DAC wil be MCP4922 dual 12bit DAC.
For the reference I intend to use MCP1541 but here I am not sure. I may also use a trimmable reference since I want to be precise for the 4.096V value.

For the current measurement I wanted to use INA210 or similar from TI but they are not cheap and hard to find. Also TI sample program is a nightmare. So I decided to use a opamp and a PNP to read the high-side current.
The opamp that I want to use is MCP6022 (2 OPA per package) . I need to use this opamp since it needs very low offset and full rail-to-rail input/output.
The other opamps that I have are not well suited for this job (some have bigger offset or/and not rail-to-rail in/out).

The ILIM loop and voltage loop are made fully in analog domain. I do not want to make it in software since may create issues later and also because I have more experience with the analog than PIC software. The other reason is that it is easier to debug and they are modular.

For the voltage divider I use a buffer since the ADC require low inpedance input source and a simple resistor divider will not work well.

I added below the full schematic that I have now. It is still a work in progress so I do not encourage anyone to think that is fully functional or that is tested. It is just a schematic made based on my knowledge.

LabPicSupply version 1 (pdf file)

LabPicSupply BOM list

Power soft switch

I want to describe here some schematics for a power switch. The soft power switch is in fact a electronic switch ( no relay, no moving parts) that can be used as a ON/OFF for a certain device.

The classical way to switch ON/OFF a device is to use a flip switch like this :

But this mechanical switch is expensive and can break  after a wile.

The other big disadvantage is that it require the mains AC line (supply line) to physically pass through that switch. So if for example you want to put the ON/OFF switch on the front panel of a device you have to go there with AC 110/220V mains. This can create problems (noise, interference…)

Beside this some people want a “fancy” ON/OFF function with only a simple push button. Like this:

So The switch is very small and can be integrated directly on the PCB board. Beside this there is very small voltages/current passing so there is no risk of electroshock.

Usually this type of application use DC voltages in the 3-24V domain. They are used often to start a board that has micro-controller or a small electronic device.

The following possibilities are shown below:

1: power_soft_switch

2:

power_soft_switch2

3:

4:

5:

6:

7:

8:

9:

10:

11:

12:

13:

14:

install Debian on USB stick for a ATOM board based server

I have a Intel ATOM board D525MW and I use this for a small home server. Normally the Intel support for Linux is not great but the ATOM boards are special. They are forced (by Intel) to boot only from disks that have FAT bootable partition. So how to install Linux ( Debian Wheezy in my case) ? First I have to trick the ATOM board BIOS to think that the USB stick boots from FAT partition . To do this I have to create a small ( 10MB ) partition formatted with FAT16. I set this to be bootable. But the partition is empty and is never used. Then I create a second partition with EXT2 ( or ext3, ext4…) and I install my Debian on it. So the Debian system will be installed in to a second partition.
How to create a USB stick with this arrangement ? Answer : with fdisk.

Insert the USB stick into a USB port and from linux terminal type (you must be root !):

# fdisk /dev/sdb (or sdc or sdd or whatever is the device name in your case)

then delete (d) all the partitions and create (n) a new FAT16 partition with 10MB and set it bootable

Then write (w) the changes to the disk and unplug the USB stick.

Then plug it again so that the OS read the new partition.

Then create (n) a second partition in the available space. For this use a Linux compatible format like ext2, ext3 or ext4. You can create now any partition scheme you want.

Then write (w) the changes to the disk and unplug the USB stick.

Then plug it again.

Now you are ready to format the partitions.

Use mkfs.msdos to format the FAT16 partition

example of the command used :

# mkfs.msdos -v -F 16  -n LABEL /dev/sdb1

Use mkfs.ext2 to format the second partition with command:

# mkfs.ext2 -v /dev/sdb2

Then umount the USB stick and unplug and plug it again.

Now you are ready to install the Debian ( or whatever distro you want). As a reminder the special arrangement with FAT16 partition is only for Intel ATOM boards because the manufacturer did not solved yet this BIOS bug.

The Debian installation is using debootstrap method. In this method the Debian OS is installed directly on a USB stick. The is no Live install ,there is no CD/DVD involved, there is no ISO burning. You need just a Linux machine, a internet connection and a USB stick formatted like described above.

First create a empty folder to mount the USB stick (preferable on /tmp/usb ). I will assume here that the USB stick is sdb and the sdb1 is FAT16 and sdb2 is ext2 partition. I will assume that we install Debian Wheezy 32bit (i386) with GRUB and no GUI, standard system . The only server installed will be SSH but from there you can add whatever you want ( FTP, Samba, Web , …). All the commands below are run from root account.

# mount /dev/sdb2 /tmp/usb/
# debootstrap --arch=i386 wheezy /tmp/usb/ http://ftp.be.debian.org/debian

adapt the command to your needs. read “man debootstrap” if you are not sure. This step will take some time ( 20-30 minutes depending on your network speed)

Then configuration of the new Debian image.

# mount -t proc none /tmp/usb/proc
# mount -t sysfs none /tmp/usb/sys
# mount -o bind /proc /tmp/usb/proc
# mount -o bind /dev /tmp/usb/dev
# mount -o bind /sys /tmp/usb/sys
# LANG=C chroot /tmp/usb/ /bin/bash

Now you enter in chroot mode. The commands that you execute now are inside the new Debian Wheezy OS.

root@debian # mount devpts /dev/pts  -t devpts
root@debian # blkid

the purpose is to find UUID identifier of the dev/sdb2 partition because we will need later the UUID code.

To edit the configuration files you can use various methods: nano, vi, etc… ( personaly I prefere nano)

next edit the /etc/fstab file

root@debian # nano /etc/fstab

and add there the folowing :

# UNCONFIGURED FSTAB FOR BASE SYSTEM
proc /proc proc defaults 0 0
UUID=insert-here-your-UUID / ext2 defaults,noatime 0 1
#/dev/sda1 / ext3 defaults,noatime 0 1
tmpfs /tmp tmpfs defaults,noatime 0 0
tmpfs /var/tmp tmpfs defaults,noatime 0 0
tmpfs /var/run tmpfs defaults 0 0
tmpfs /var/log tmpfs defaults 0 0
tmpfs /var/lock tmpfs defaults 0 0

Then edit your network card config file: nano /etc/network/interfaces

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

Then configure your local timezone with

root@debian # dpkg-reconfigure tzdata

then edit you server network name ( the machine name in the local network)

root@debian # nano /etc/hostname

Then edit the sources.list for the apt-get/aptitude:

root@debian # nano /etc/apt/sources.list

add there the folowing (edit them to match your needs) :

deb http://ftp.be.debian.org/debian wheezy main
deb-src http://security.debian.org/ wheezy/updates main
deb http://secirity.debian.org/ wheezy/updates main

Then make refresh for the aptitude packages with:

root@debian # aptitude update

next install the locales :

root@debian # aptitude install locales
root@debian # dpkg-reconfigure locales

Next install console-data, linux image and grub:

root@debian # aptitude install console-data
root@debian # aptitude install linux-image-486
root@debian # aptitude install grub

next edit the grub config file like this:

root@debian # nano /etc/default/grub

and inside add something like this :

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
#GRUB_CMDLINE_LINUX_DEFAULT="verbose console=ttyS0,38400n8 reboot=bios"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=38400"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console
#GRUB_TERMINAL=serial

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Then open a new terminal in your Linux machine ( outside the chroot !) and add this in the /boot/grub/device.map :

(hd0) /dev/sdb

Then update the grub configuration (you are now back on the chroot environment) :

root@debian # grub-install /dev/sdb
root@debian # update-grub

Please check and edit the /boot/grub/device.map so that your USB stick is on hd0 and not hd1.

Then check if you have hd1 in the /boot/grub/grub.cfg. If yes then please replace it with hd0

Now change the root password for your new Debian Wheezy:

root@debian # passwd root

Next install the utility packages like sudo, ssh-server, standard Debian packages…or whatever you want to install :

root@debian # aptitude install rsyslog sudo
root@debian # tasksel install standard
root@debian # tasksel install ssh-server

now the installation is finished and you need to exit from chroot environment. Please be careful that if you do not use the correct exit method you can damage the newly installed OS.

So do :

root@debian # umount /dev/pts
root@debian # exit

So now you are not in chroot anymore and you are back at your linux terminal.

Now umount :

# umount /tmp/usb/proc/
# umount /tmp/usb/sys
# umount /tmp/usb/dev
# umount /tmp/usb
# umount /dev/sdb2

Now you are ready to unplug the USB stick and to use it on the ATOM board !