All posts by EEadmin

I2C to 5V slave using Pi zero

Just a link that says it all..

https://nathan.chantrell.net/20120610/raspberry-pi-and-i2c-devices-of-different-voltage/

You can connect 5V slave devices via I2C, although it will work, it’s out of spec.

Great trick to level shift using 2 resistors and two MOSFETS

i2c_level_shifter

Thanks to Nathan Chantrell for the confirmation that it will work.

 

High speed I2C on PI Zero

After playing with the I2C bus on the Pi Zero I found that I was unable to change the baudrate with either of the commands

modprobe i2c_bcm2708 baudrate=200000

or

gpio load i2c 2000

Apparently you now need to set the I2C speed in /boot/config.txt

Mine now reads:

dtparam=i2c_arm=on
dtparam=i2c1=on
dtparam=i2c1_baudrate=500000

Of course it does need a reboot to change.

Strangely dtparam=i2c1_baudrate=1000000

won’t work, but that may be due to my receiver and not the PI

 

Headless Raspberry PI (PIZero) setup

The PIZero Simple setup without network or monitor. (Requires some prior knowledge of RS232 adapters and serial port setup)

First start by getting a PI SD image I used Raspian Jesse Light https://www.raspberrypi.org/downloads/raspbian/

Install into a sd card and make sure it runs (green light at least)

With a 3.3v RS232 adapter connect earth and RX/TX to your PI. Be careful some adapters are only 5V and will damage your PI’s UART pins.

PiZero

Setup your PC (I use Tera Term) serial adapter for 115200, 7 bits, even parity, 1 stop bit.

Boot your PI

If you get a screen of gobbledegook then good, otherwise swap your TX and RX around. When the gobbledegook has finished, press return a couple of times, and you should get a login prompt.

For some reason the console and boot up output at different baud rates (Caused by auto baud rate detect, settings above amended so this shouldn’t happen now)

Configure your PI the usual way. You will need some network to get your updates, but apart from that you have a working PI.

If you are brave (or idle) you can connect the +5v line from your serial adapter to power your PI too so you don’t need another usb power lead. Just be very careful that you attach it to the correct pins, otherwise your PI will be damaged.

 

Useful links.

(although I found the baud rate setting wrong everywhere I looked. Either auto baud rate detect at work, or it changes from distro to distro)

Element 14 no display using the raspberry pi serial console

RPi Serial Connection

 

Update:

The baud rate is auto detected, the native speed is 115200 (amended above) The auto detection only happens at the login prompt. The auto detection won’t pick up changes in bits/stop bits/ or parity. You can change the console getty port/speed/parity settings look at RPi serial connection above.

WiFi

If you have a wifi adapter and micro USB to USB lead, you can connect to WIFI. After connecting via RS232 edit the file /etc/wpa_supplicant/wpa_supplicant.conf using sudo nano

add in the lines

network={
    ssid="Your_WIFI_SSID"
    psk="Your_wifi_password"
}

and reboot the pi sudo shutdown -r

re log in to the pi and type ifconfig to fins the wifi IP address. 
Then you can ssh to your PI and even better update the software.

Note : for Pi 3. You may need some changes to get the headless conf working, especially at non default baudrates, take a look at http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two

 

 

 

 

 

 

 

The 1MV Tesla coil myth – Spark growth

It is often said to me that a Tesla Coil produces 1,000,000 V or more.

This is a common misconception. Unless you have an absolutely huge Tesla coil, the actual voltage at the top load is much smaller.

The mistake comes from the widely accepted rule of thumb that the voltage that an electrical discharge will jump determines the voltage present, in normal air at atmospheric pressure this equates to 30Kv per cm .  [Paschen’s Law] So it is easy to see that if a tesla coil produces sparks that will jump 30 cm or so, this means that the voltage on the top load must be roughly 1MV.

Unfortunately the situation on a tesla coils top load is a bit more complicated and the 30KV/cm rule does not apply in quite the same way.

The physics of the arc itself needs to be taken into account and the Radio frequency AC that is created. The Tesla coil is effectively a high voltage, high impedance AC current source [Tesla Coil – Output voltage] . So when the spark is being created as the spark grows it forms a  capacitor that draws current from the tesla coil reducing the top load voltage.  This effect happens as soon as the torroid breakdown voltage has occurred and gets progressively worse as the spark leader forms. This is therefore governed by the voltage breakdown of the minor diameter of the tesla coils top load

The maximal achievable potential is approximately equal to the sphere radius R multiplied by the electric field Emax at which corona discharges begin to form within the surrounding gas. For air at STP the breakdown field is about 30 kV/cm –  [https://en.wikipedia.org/wiki/Van_de_Graaff_generator]

So the voltage on the top load of a tesla coil tends to be slightly more than the standoff voltage of it smallest diameter.  Vmax = R·Emax (R = Radius, Emax = Breakdown voltage in air 30Kv). For a teslacoil with a 20cm (minor) diameter top load this is around (20cm/2) * 30Kv = 300Kv

The minor diameter is d
The minor diameter is d

But… 300Kv will only give sparks of 10cm according to the 30Kv/cm rule, Tesla coils can easily achieve better than that?

This is where the second aspect of the tesla coils output comes in to play. The voltage on the top load is both AC and Pulsed. Each burst or pulse of Radio Frequency (RF) creates a 10cm long (using the example above) arc leader from the available 300Kv. This heats and ionizes the air, making it conductive this is what you see as the arc in the air.

If very rapidly after the first burst of RF comes another,  the channel won’t have had time to dissipate so there is a conductive channel the new pulse can use. The energy rushes to the end of this ionized channel and tries to create another 10cm leader there. Not only does this almost double the spark length, but the energy also re-ionizes  the channel. This continues with the third, fourth, n … pulses, each time adding on a slightly diminishing (due to losses) leader to the existing spark.

This continues until something disrupts the channel usually the air rising as it get hot.

This can be easily proved with a modern electronic tesla coil. Set the coil to produce a single burst of RF, this gives a discharge that can be measured using the 30Kv/cm rule and can give a fairly accurate indication of the terminal voltage.

So unless you see a tesla coil with a 66cm minor diameter top load it isn’t producing 1MV

The BIGG coil of Oklahoma, probably the only true 1MV tesla coil.

Save

Static electricity doesn’t exist

Yes, I know, its was taught to you at school. Me too.  I even have a book that has separate chapters of static electricity and conventional current electricity. So what is the problem, well it took me years to work out that there is no such distinction. Its all electricity. Static electricity on the terminal of a VDG sphere doesn’t suddenly transform in to current electricity when it is discharged and current electricity doesn’t transform into static when its stored in a capacitor.. The same rules must apply to both.

To use the water analogy, water is the same if its in a lake or  in a stream.

I’m my mind I can’t think of any situation where static electricity exists. Capacitors, Van de graph terminals (also capacitors) all store charge. But non are static, there is always leakage current. To charge these devices there must be current.

So is its not static electricity, its stored electricity (charge) or conventional electricity(current) ,  both or just electricity.

Reading Physics books there appears to be a whole set of laws that govern each “type” of electricity, but in reality the effects are always there. One of the problems is that ‘static’ electricity is generally taught with high DC voltages, current electricity is taught with low DC voltages. The effects you see are dominated by the voltage, for example.

Electrical attraction occurs in all capacitors. But at high voltage the effects are much larger and so easier to see.
Resistive heating has a larger effect at low voltages, but is harder to see at high voltages (which is why transmission lines are high voltages)

The more you work on high voltage, or with high frequency electricity the more these effects become apparent.

So banish ‘static’ as a description and replace with high or low voltage, charge or current this is really what is going on.

Bill Beaty’s Thoughts on this What’s the Difference Between ‘Static’ Electricity and ‘Current’ Electricity?

1MV Van De Graff project – Notts Gaussfest

After a lot of work, I just managed to get everything to Notts Gaussfest. This was really the first time all of the pieces had run together for any length of time.

I found a number of issues. The belt stuck together at high charges, usually stopping the belt completely and the motor control would crash when there was a really good discharge.

The motor problem was a partially solved by coating the controller in aluminium foil, which at least let me run the VDG for the day at Notts Gaussfest.

 

 

1MV Van de Graff – First light

Details of the project

First light tonight 6″ sparks, not bad for the first time I’ve powered it up.

At the moment the limiting factors to the spark length/voltage is the unfinished top load and a problem with the belt. The top load has a very uneven surface, I believe I’m losing charge this way.

When the VDG starts charging the two sides of the belt are attracted to each other and they rub together, reducing the charging. I tried tightening the belt with no effect, so I have ordered 0.4mm (was 0.25mm) latex to make another thicker belt.

Work continues to complete the top load.

I2C control of LCD Display using YwRobot LCM1602 V2 & Raspberry PI

Using the YwRobot to control a 20×4 line display via I2C on a Raspberry PI, what could be easier.
PI display
Well, If all of the code was only for an arduino and there being no actual documentation or wiring diagram. Note: Example code IS NOT documentation.

Hey Ho, After some playing around I found the pin arrangement


addr, en,rw,rs,d4,d5,d6,d7,bl
0x27, 2, 1, 0, 4, 5, 6, 7, 3

0x27 is the i2c port address (bus 1 on newer PI’s)

I found this code snippet for a different set of boards http://www.rpiblog.com/2012/07/interfacing-16×2-lcd-with-raspberry-pi.html which was near, but made the display backlight flash and no text output.

So the hacking started…

Basically all of the control lines were on different pins, and I needed to control the backlight (via a wrapper on the i2c write code)

pylcdlib.py
import smbus
from time import *

#
# Modified from http://www.rpiblog.com/2012/07/interfacing-16×2-lcd-with-raspberry-pi.html to run
# 20×4 line display with YwRobot LCM1602 IIC V1 backpack
#

# General i2c device class so that other devices can be added easily
class i2c_device:
def __init__(self, addr, port):
self.addr = addr
self.bus = smbus.SMBus(port)

def write(self, byte):
self.bus.write_byte(self.addr, byte)

def read(self):
return self.bus.read_byte(self.addr)

def read_nbytes_data(self, data, n): # For sequential reads > 1 byte
return self.bus.read_i2c_block_data(self.addr, data, n)

class lcd:
#initializes objects and lcd
”’
Port definitions
addr, en,rw,rs,d4,d5,d6,d7,bl
0x27, 2, 1, 0, 4, 5, 6, 7, 3

”’

def __init__(self, addr, port):
self.lcd_device = i2c_device(addr, port)

self.backlight=1; #default to backlight on

def lcd_init(self):
#set 4 bit mode
self.lcd_device_writebl(0x30) #write
self.lcd_strobe()
sleep(0.005)
self.lcd_strobe()
sleep(0.005)
self.lcd_strobe()
sleep(0.005)
self.lcd_device_writebl(0x20)
self.lcd_strobe()

self.lcd_write(0x28)
self.lcd_write(0x08)
self.lcd_write(0x01)
self.lcd_write(0x06)
self.lcd_write(0x0C)
self.lcd_write(0x0F)

#wrapper to self.lcd_device.write fir backlight control
def lcd_device_writebl(self,value):
if self.backlight:
self.lcd_device.write(value | 0x08);
else:
self.lcd_device.write(value)

# control backlight on=1 or off=0
def lcd_backlight(self,on):
self.backlight=on
self.lcd_strobe()

# clocks EN to latch command
def lcd_strobe(self):
#bit 2
self.lcd_device_writebl((self.lcd_device.read() | 0x04))
self.lcd_device_writebl((self.lcd_device.read() & 0xFB))

# write a command to lcd
def lcd_write(self, cmd):
self.lcd_device_writebl((cmd >> 4)<<4)
self.lcd_strobe()
self.lcd_device_writebl((cmd & 0x0F)<<4) self.lcd_strobe() # self.lcd_device_writebl(0x0) # write a character to lcd (or character rom) def lcd_write_char(self, charvalue): self.lcd_device_writebl((0x01 | (charvalue >> 4)<<4))
self.lcd_strobe()
self.lcd_device_writebl((0x01 | (charvalue & 0x0F)<<4))
self.lcd_strobe()
self.lcd_device_writebl(0x0)

# put char function
def lcd_putc(self, char):
self.lcd_write_char(ord(char))

# put string function
def lcd_puts(self, stringin, line):
if line == 1:
self.lcd_write(0x80)
if line == 2:
self.lcd_write(0xC0)
if line == 3:
self.lcd_write(0x94)
if line == 4:
self.lcd_write(0xD4)

string=stringin + ” ” #blank out rest of line
string=string[0:20];#limit lines to 20 char

for char in string:
self.lcd_putc(char)

# clear lcd and set to home
def lcd_clear(self):
self.lcd_write(0x1)
self.lcd_write(0x2)

def lcd_cursoroff(self):
self.lcd_write(0x0c) #cursor and blink off

# add custom characters (0 – 7)
def lcd_load_custon_chars(self, fontdata):
self.lcd_device.bus.write(0x40);
for char in fontdata:
for line in char:
self.lcd_write_char(line)