Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Friday, October 27, 2017

Remote SOund Navigation And Ranging(SONAR) Application with Raspberry Pi 2 in the Local Network Area(LAN)

Hello everybody, today I am here with another post. I will construct a remote SONAR application using Raspberry Pi 2, servo motor and HC-SR04 ultrasonic range sensor. In order to understand this post better, please check the previous posts that I have already written.

1 - Controlling Servo Motor using Raspberry Pi, Python (RPi.GPIO) software based Pulse Width Modulation(PWM)
2 - Using HC-SR04 Ultrasonic Range Sensor with Raspberry Pi 2

What do we need?

1 - Raspberry Pi 2
2 - HC-SR04 Ultrasonic Range Sensor
3 - Micro Servo Motor
4 - 1x1kΩ and 1x2.2kΩ Resistors
5 - Bread Board
6 - Jumper Male to Female Wires
7 - Laptop(for remote communication)

We need all the components above. But, if you want to display the results on Raspberry Pi locally, then you don't need a Laptop. However, here I will use Laptop. Because, Raspberry Pi is a small board which is used for remote applications generally.

Here is the technical description.

1 - My laptop's config(It will be the client machine):

- IP Adress:192.168.1.106
- Communication port is 9000
- Operating System: Windows 10
- This will be the client machine

2 - My Raspberry Pi's config(It will be the server machine):

- IP Adress:192.168.1.108
- Communication port is 9000
- Operating System: Raspbian Jessie Lite
- This will be the server machine

Thursday, October 26, 2017

Using HC-SR04 Ultrasonic Range Sensor with Raspberry Pi 2

The HC-SR04 ultrasonic range finder is a sensor that provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit. It is very cheap and simple to use, however the signal output needs to be converted from 5V to 3.3V so as not to damage the Raspberry Pi. I will introduce some Physics along with Electronics in this tutorial in order to explain each step. But first, we should have the following components:

1 - Raspberry Pi 2 Model B
2 - HC-SR04 Ultrasonic Range Sensor
3 - 1x1kΩ and 1x2.2kΩ Resistors
4 - Bread Board
5 - Jumper Male to Female Wires

Ultrasonic Range Sensors and How do they works?

There are two types of ultrasonic range sensors: active and passive. An active sensors set sends out sound pulses called pings, then receives the returning sound echo. Passive sensors sets receive sound echoes without transmitting their own sound signals.

How HC-SR04 ultrasonic range sensor works? It is an active sensor and basically, it creates a pulse of sound, often called a "ping", and then listens for reflections (echo) of the pulse. If you check the following images. You will understand the concept better.


Sunday, October 22, 2017

Controlling Servo Motor using Raspberry Pi, Python (RPi.GPIO) software based Pulse Width Modulation(PWM)

Hello everybody. Today I am going to talk about controlling servo motors using Raspberry Pi. A servo motor is a rotary or linear actuator that allows for precise control of angular or linear position, velocity and acceleration. This project uses Python script, which uses RPi.GPIO library, run on a Raspberry Pi micro controller to send General-purpose input/output(GPIO) Pulse Width Modulation(PWM) outputs to a servo motor to set its angle. However, it is not an easy task since PWM period cannot be defined by the user. It is servo motor and manufacturer-specific.

For this project, I used the following items:

1 - Raspberry Pi 2 Model B
2 - Micro Servo Motor
3 - Jumper Male to Female Wires

The Raspberry Pi 2 has 40 pins and you can see the explanation of each pins below. The servo motor has three terminals. We need to connect these 3 terminals to the proper pins of Raspberry Pi.

1 - Position signal(PWM Pulses)
2 - Vcc (From Power Supply)
3 - Ground

Friday, February 8, 2013

Web2py ve Yeni Başlayanlar İçin Temel Bilgiler

Herkese merhaba, yaklaşık 1 aydır "Web2py" ile uğraşmaktayım. Bilmeyenler için kısaca tanımlamak istiyorum. Web2py, web uygulamalarınız için kullanabileceğiniz Python ile yazılmış bir framework. Hemen hemen Django Framework'ü ile aynı özelliklere sahip olsada, aralarında bazı temel farklar da bulunmakta. Öncelikle aralarındaki bu farklardan kısaca bahsetmek istiyorum.

  • Django MTV(Model, Template, View) yapısı kullanırken, Web2py MVC(Modeli View, Controller) yapısı kullanır.
  • Web2py, web uygulamanızı geliştirmenize olanak sağlarken, Django uygulamanızın tüm detaylarına hakim olmanızı ve tasarımınızı görünürde olmasa bile kafanızda bitmiş olmasını ister.
  • Web2py, sizden her şeyi import etmenizi beklemez ama Django ile uygulama geliştiriyorsanız hemen her şeyin import edilmesi gerekir.
  • Her iki frameworkte geriye dönük destek sağlamaktadır.
  • Web2py otomatik kendiliğinden veritabanınızı migrate eder, ancak Django bunu yapmaz.
  • Her iki frameworkte shell üzerinde işlem yapmanıza olanak sağlar.
  • Web2py kendiliğinden "View"ları belirleyip render eder. Fakat Django bunu yapmaz.
  • Her iki frameworkte "layout" modelini destekler.
  • Web2py, 2 tip yönetim paneline sahiptir. Bunlardan ilki uygulamayı geliştirdiğiniz yönetim paneli, diğeri ise admin yönetim panelidir. Buna karşılık Django tek yönetim paneline sahiptir. Ancak Web2py framework'üne göre daha detaylı ve iyidir.
  • Web2py, Django'dan daha rahat bir template sistemine sahiptir. "endif", "endfor", "endifequal", "endifnotequal" gibi ifadeler yerine her şey "{{ }}" ve "{{ pass }}" etiketleri arasında yapılır. Geliştirici için büyük kolaylık sağlar.
  • Web2py, Python ifadelerini "View"larınızda rahatça kullanmanıza olanak sağlar. Ancak Django bu desteği vermez.

Tuesday, August 7, 2012

Windows'a Django 1.4.1 Kurulumu

Django, çok uzun zaman önce duyduğum fakat zaman sıkıntısı sebebiyle hiç alakadar olamadığım Python programlama dili için hazırlanmış ve BSD lisansı ile lisanslanmış yüksek seviyeli bir web çatısıdır. Basit kurulumu ve kullanımı, detaylı hata raporu sayfaları ve sunduğu yeni arayüz kodlama yöntemleriyle diğer sunucu yazılımı ve çatılardan kendini ayırmaktadır. İsmi, ünlü jazz gitaristi Django Reinhardt'tan gelmektedir.

Bu yazımda Django 1.4.1'in Windows XP üzerine kurulumunu anlatacağım. Öncelikle bize lazım olan uygulamaların bir listesini çıkaralım. Django, Python programlama dili kullanılarak geliştirildiği için sistemde Python kurulumu olması ön şart. Ancak GNU/Linux dağıtımlarının aksine, Windows işletim sisteminde Python programlama dili kurulu olarak gelmez. Dolayısıyla Python’ı Windows’ta kullanabilmek için sitesinden uygun kurulumu indirmemiz gerek.

İlk olarak şu adresten hangi Python sürümünün hangi Django sürümü ile uygun olduğunu kontrol etmeliyiz. Benim bu yazıyı yazdığım tarihlerde Django 1.4 sürümü için Python 2.5, 2.6, 2.7 sürümleri birbirleri ile uyumlu sürümler idi. O yüzden Python kurulumunu 2.7, Django kurulumunu 1.4'e göre yapacağım. Fakat siz istediğiniz sürümü kullanmakta özgürsünüz bu yüzden istediğiniz Python sürümü için [http://www.python.org] sitesinden, istediğiniz Django sürümü için ise [https://www.djangoproject.com] sitesinden uygun sürümleri indirmemiz gerekiyor. Ya da benim bu yazı için kullandığım Python 2.7.3 sürümünü indirmek için buraya, Django 1.4.1 sürümünü indirmek için buraya tıklayınız.