Proton BASIC Compiler - Wind counter of making your own transfomers

  • PicŪ Basic

  • Wind counter of making your own transfomers

    hi all

    i have designed a very simple wind counter using a pic 16f676 cheap and easy

    feel free to try it build it go mad and enjoy

    '************************************************* ***************
    '* Name : wind counter.BAS *
    '* Author : [Jody Botha] *
    '* Notice : Copyright (c) 2011 [Tachyon Tech sa] *
    '* : All Rights Reserved *
    '* Date : 4/12/2011 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    ' Building a home style winding machine????
    ' here is a simple counter using a pic 16f676 chip with a reset button
    Device = 16F676 'ITs one cheap 14pin chip
    Declare Xtal = 4 'crystal speed
    Declare All_Digital = true 'all pins digital
    CMCON = 7 'disable all analog
    Declare LCD_DTPin = PORTC.0 'set your display data line from portc.0 to portc.3
    Declare LCD_RSPin = PORTC.4 'set rs pin to portc.4
    Declare LCD_ENPin = PORTC.5 'set enable pin to portc.5
    Declare LCD_Interface = 4 'set amount of data lines to the display
    Declare LCD_Lines = 2 'set amount of lines
    Declare LCD_Type = 0 'set lcd type to 16 char x 2 line
    Declare LCD_CommandUs = 2000
    LCD_DataUs = 50
    'DECLARE FLASH_CAPABLE = FALSE 'might be needed if you your display does not funtion
    TRISA =%00000011 'setting portA.0 and portA.1 as inputs
    TRISC =%00000000 'setting all your port c pins to output
    DelayMS 100 'Wait for things to settle
    Cls 'Clear the LCD
    Dim dev As Dword 'create a dword varible as to make the numbers active
    Print At 1,1," WIND COUNTER " ' /start up screen
    Print At 2,1," BY JODY BOTHA " ' \ and yes my name of coarse

    DelayMS 4000 'display it for 4 seconds

    Cls 'then clear the lcd for the start

    PORTA.0 = 0 Then 'if the button is pressed then
    dev = dev +1 'add one count
    GoTo debounce 'goto next loop to debouce
    End If 'see in compiler manual if,then,end if commands
    Print At 1,1,"Turns : ",Dec6 dev 'send lcd : turns : 000000
    If PORTA.1 = 0 Then 'if the button is pressed
    DelayMS 5 'wait for stablisation
    dev = 0 'Clear the accumulated amount
    End If

    Print At 1,1,
    "Turns : ",Dec6 dev 'update dsplay and show its not relooping from prolong button press
    If PORTA.0 = 1 Then 'when you let go of the button its ready to add another count
    DelayMS 5
    GoTo loop
    End If
    'create a loop
    kind regards

    Jody Botha
    This article was originally published in forum thread: Wind counter of making your own transfomers started by JODY View original post
  • Recent Activity


    Beta Testers Wanted

    Thread Starter: towlerg

    Actually, it's probably more alpha. While adding endless PRINT statements to show intermediate results, it occurred to me that there had to be a...

    towlerg Yesterday, 19:57 Go to last post

    Include a include file only once

    Thread Starter: towlerg

    I'm writing library files for various sensors. The code for the sensors will be in .INC files and the RAM dimensioning will be in .H files. For...

    towlerg Yesterday, 19:26 Go to last post