Menu

Making the jump from Picaxe

Help
2018-02-25
2018-03-25
1 2 > >> (Page 1 of 2)
  • Mario Zandel

    Mario Zandel - 2018-02-25

    Hi everyone.
    I have been programming Picaxe chips on and off for a couple of years now. Decided it was time to move on and try some native PIC programming. I watched some tutorials where they used Mikroc and thought I would try that. Couldnt get a flashing LED no matter what I tried, so I decided to look around for something better. I found GCB and was flashing an LED in an hour of finding the software, so congrats to all on a great compiler!
    I have an old Velleman K8048 PIC Programmer board that I am using at present with a Pickit3 atatched. Now that I have been able to flash an LED I want to move on to detecting a button press. I cant seem to figure it out.
    Can anyone point me to an article on how to detect which one of four buttons was pressed?
    Thanks in advance.
    Marz

     

    Last edit: Mario Zandel 2018-02-25
    • Anobium

      Anobium - 2018-02-25

      @Mario.

      Welcome.

      You will enjoy Great Cow BASIC. There are many converts here.

      Ask questions, there is a learning curve but others have been there before you.

      Re the PicKit3 - there is some good news coming on this from us, but, meanwhile, you will need to update the PicKit3 software and the underlying database. You will find this in your Great Cow BASIC installation folder - reinstall the GUI software then update the .dat file provided.

      Re the K8048. I put mine in the bin. There a lots and lots of much better boards. From a learning experience I would recommend the Microchip Xpress Board - a 16f18855. It will reduce your learning curve hughly.

      And, you may want to walk through a set of demos. See your installation. ..\GreatCowBasic\Demos\Vendor Boards\Microchip - Low Pin Count Demo Board\PICKit3 Board\16F1829 Whilst this may not be your chip (cus that would be so lucky!) you can just adapt these demos for your select chip and board. I used to use the AXE091 board for all prototyping about 5 years ago.

      Yes, I am exPicaxe.

      Anobium

       
  • kent_twt4

    kent_twt4 - 2018-02-25

    No doubt there is an example in the demo folder or by using search. But here you go, make the button pin an input, check for the button going high or low (low is used in below example), debounce the switch in software or hardware, then toggle the led.

    So some ideas to incorporate into your code.

    'define and assign button to port pin
    #define button0 PortB.X
    #define led0 PortB.Y
    'make the button an input
    Dir button In
    Dir led0 Out
    led0 = 0
    
    Start:
      'read the button
      If button0 = 0 Then
        Call debounceButton
        If debounce = True Then
          led0 = NOT led0
        End If
      End If
    goto Start
    
    sub debounceButton
      debounce = False
      glitch = 0
    Do
      If button = 0 Then
         debounce += 1
      else
         glitch += 1
      end if
      wait 10 ms
      If debounce > 2 Then
        debounce = true
        exit Do
      End If
      If glitch > 1 Then exit Do
    Loop
    end sub
    
     
  • Mario Zandel

    Mario Zandel - 2018-02-26

    @Annobium, I thought I had seen you before on the Picaxe forum. no 16f18855s lying around, but do have a few 20M2s ;)
    Looking into one of those development boards. I did have problems getting GCB working on my Win10 machine, but works on my win7 one perfectly. as for using the correct Pickit3 settings, I think that might be the issue on my win10 machine. how do you know which of the Pickit3 lines to uncomment? Also seems likr there are a few different versions of the pickit software. As this is new to me the configuring of Pickit 3 and GCB to work together is a little confusing. How do you update the .Dat file?
    @kent_twt4 I was hoping there is a read port directive of some sort, like the Picaxe program I am trying to replace. I have 6 buttons on a remote that I need to know which is pressed. Also have a switch on the remote that pulls a pin high to give me another 6 button functions.

     
  • Mario Zandel

    Mario Zandel - 2018-02-26

    Did a bit of digging, and Would (Whatever variable) = PORTA be what I am looking for? Is there a port mask that can make the value of the 2 pins I am not using Irrelevant? Then I was going to put the variable into a select case statement. Is that a good way to go about it?

     
  • Anobium

    Anobium - 2018-02-26

    Lots of questions. I am surprised Stan has not waded in.

    @Annobium, I thought I had seen you before on the Picaxe forum. no 16f18855s lying around, but do have a few 20M2s ;)

    Not been on the Picaxe forum for a while. But, it was one of the senior Picaxe fellas that told me go looking for a proper compiler to support what I want to achieve in terms of control and speed. I found Great Cow BASIC.


    Looking into one of those development boards. I did have problems getting GCB working on my Win10 machine, but works on my win7 one perfectly. as for using the correct Pickit3 settings, I think that might be the issue on my win10 machine.

    Many others have Great Cow BASIC installed and operational under Windows 10. Including myself. Create a new thread on this subject so we can share a focused Windows 10 thread.


    how do you know which of the Pickit3 lines to uncomment?

    Currently, PicKit3 can program a chip via the PicKit3 GUI and/or MPLAB-IPE (a Microchip download). Howerver, keep watching this forum for news on this.

    My advice as a newbee. Use the PicKit3 GUI for the short term. Also, see this video.


    Also seems likr there are a few different versions of the pickit software. As this is new to me the configuring of Pickit 3 and GCB to work together is a little confusing. How do you update the .Dat file?

    If you have installed the PicKit3 GUI software from the Great Cow BASIC installation. From the folder PicKit3GUI. Find the installation folder PicKit3GUI and then copy the PK2DeviceFile.day from the PicKit3GUI\Updated DAT file to this installation folder. This will provide you greater support for a wider range of microcontrollers.


    @kent_twt4 I was hoping there is a read port directive of some sort, like the Picaxe program I am trying to replace. I have 6 buttons on a remote that I need to know which is pressed. Also have a switch on the remote that pulls a pin high to give me another 6 button functions.

    Tucked away in Kents code is a portb.X constant. This constant addresses what you want to do. Then Kent uses If button0 = 0 Then to check the state of the port.

    Here is the link the Help. http://gcbasic.sourceforge.net/help/ This page specifically explains the use of reading and writing to the port. http://gcbasic.sourceforge.net/help/_inputs_outputs.html


    @Stan. Where are you when a new Picaxe convert arrives? :-)

     
  • Mario Zandel

    Mario Zandel - 2018-02-26

    @Annobium, thanks for all that info. I reckon that will keep me busy for a while. Looks like I'll have another go at getting it running on my Win10 machine. Only other thing i need to do is pick a new development board . At this point i am focusing on 8 bit PICs, as i am redesigning an existing project that I will probably release all the relevent files when finished. Therefore I really want a development board that can programme 8 to 40 pin PICS. Any ideas anyone?
    Marz

     
    • Anobium

      Anobium - 2018-02-26

      The development board - an Xpress Board.

       
  • Mario Zandel

    Mario Zandel - 2018-02-26

    MPLAB® Xpress Evaluation Board (DM164140) not available in Australia that I can see. But I can get a DM160228 Explorer 8 PIC 8-Bit Development Board. Is that a good choice? That seems to be able to do a wide variety of PICs.

     
  • stan cartwright

    stan cartwright - 2018-02-26

    Sourceforge was down.
    I'd recommend a uno or nano clone. Cheap. Nothing else needed. 2K ram,fast, 28 pins.
    For pic use in-circut programming and pickit2. I found that as easy as making a picaxe board and using rs232 port to 3.5 jack. Picaxe usb lead -cost and problems.
    I wouldn't recommend a xpress board that use programmable pins pic for a new gcb user.
    Using in circuit pic programming flash old picaxe pics.

     
  • stan cartwright

    stan cartwright - 2018-02-26

    @Mario might have a picaxe dev board that could be altered. I assume people into pics etc. can solder and read a circuit. Not always though.
    I hadn't noticed @mario had a pickit3. The pics that need this seem popular but I don't see why. Please sell me why I need one. I use 18f25k22 as main pic. They were picaxe x2. Runs at 64MHz. 1.5Kram. Are newer pics better?
    After using picaxe, gcb is different in that you have many more choices for devices to use. Brill.
    Led and switch is how I started, just to see the assemble/compile/flash work. It did and I haven't looked back.
    The speed of gcb running is amazing after picaxe. I'm guessing 100+ times faster.
    Awareness of gcb is spreading on the picaxe forum. Comments vary. "It looks too complicated".....after picaxe??, "picaxe isn't slow" :), "I can do what I want with picaxe,I'm happy,why bother?"
    I did post "convert picaxe to gcb" but no interest but picaxe users trying gcb will have to convert picaxe commands to gcb. Thing is after not using picaxe for a year I've forgotten how it works. If I visit their forum it all looks so complicated, honest.
    Hope you enjoy using gcb as much as me @Mario.

     
  • stan cartwright

    stan cartwright - 2018-02-26

    I did a youtube vid showing using a uno with gcb to show how easy. https://www.youtube.com/watch?v=jWSbwn36Q3E
    Unlike picaxe, GCB is open source and ANYONE can contribute with ideas to improve it and it's dynamic and updated as new stuff is implemented.

     

    Last edit: stan cartwright 2018-02-26
    • Mario Zandel

      Mario Zandel - 2018-02-28

      @ stan I might have to dig out that UNO board and have a play....

       
  • stan cartwright

    stan cartwright - 2018-02-26

    My first and only gcb pic dev board. As you can see I'm up to date.

     

    Last edit: stan cartwright 2018-02-26
  • stan cartwright

    stan cartwright - 2018-02-26

    Why a dev board? nano suits bread board and gets results. You don't need a kit.
    Thinks.. anobium wishes site went down again. Sorry if too many posts, my thoughts were invited.
    edit note the picaxe mp3 player. works better with gcb imho

     

    Last edit: stan cartwright 2018-02-26
  • Mario Zandel

    Mario Zandel - 2018-02-27

    Hello all. I figure the best way to understand what I am trying to do is give you a bit of background. On Sundays I teach dog agility. It struck me that in the modern world we live in, no one seems to have applied modern technology to dog agility. I spend my day putting up and putting down jumps. I had the idea to make remote controlled jumps that would go up and down with the press of a button. Thought it would be a no brainer - I found out its not.
    I have a few nice toys though. A CNC Lathe, 2 CNC Mills. a 3D printer and have just taken possession of a 9 ton injection molding machine, which will make it a lot easier to make the many parts I need to make it work. I also decided along the way to make it even harder, by making the workings miniature and so invisible from the outside. They dont look much different to the ordinary jump poles, until they move. Here is the end result: https://www.facebook.com/sfdab/videos/949379378515040/

    I used Picaxes, as they were easy to program, and I had someone with a lot of excess 8M`s that I got cheap. By accident that video went on to public facebook instead of the private site for our club, and a lot of people saw it and wanted them. The only issue is they are expensive to make, therefore the idea has stalled for a while until I decide where I want to head with them. I decided to trim all the costs down to the cheapest I could possibly make them for, Hence the use of native PICS, as they are cheaper than Picaxes.
    The reason for the development board over the nano boards is all to do
    with size. There is a lot to pack into a small area with these jumps, so I have been using SMD Picaxes and my own custom boards up till now. Also there is no need for 30 pins or more so the small smd PICS are better for me. this is what is packed in there : (HMM.. Cant seem to upload a photo...)
    I have a great little system to do SMD work. Having the Milling machines means I can easily make solder masks. I also usually mill my first boards as well, but it is a lot less stress to get the boards made in China once a design is locked down- and a lot cheaper.
    Where I want this project to end has expanded somewhat from the original idea. to list the extra ideas would take too long, and you have to crawl before you can walk . I want our club to have the best agility equipment in the country, and I would like to turn the sport into an entertaining thing to watch, with a few modern technological gizmos thrown in.
    Hope that wasnt too long winded.

    Marz.

     
  • Mario Zandel

    Mario Zandel - 2018-02-27

    @ Stan, Comment as much as you like. I am sucking it all up like a sponge at the moment
    The reason I like a development board is that the thought of all those jumper wires going everywhere makes my little OCD head spin :) Id much rather have a board with onboard LEDs, Buttons, and LCD screen so I dont have to second guess my wiring and just be able to concentrate on the programming. As to unos and the like. I do have some of them. I like shiny new things. I get them home then they end up in a drawer and dont see the light of day until Im bored ( I do have a LEOFI Sweetpea that I was hoping to introduce to this projecct further down the line) As for the small Atmel boards, I do have some of them lying around somewhere with some bitwhackers as well. A project for another time. I need to retire to get all my projects under way! Alas, I still have to work for a living. Looking forward to the GCB adventure.
    Marz.

     
  • kent_twt4

    kent_twt4 - 2018-02-27

    Other thoughts
    1. An alternative to polling or reading a Port, is to use the Interrupt On Pin Change. No pin or port masking required. Plus, this feature could be used to wake from sleep to help conserve battery power. The enhanced midrange devices do a good with this, they must have some sort of internal filter built in?
    2. Never bought one of huge doit all boards like from Mikroe. Really liked the old small pin count boards (8/14/20 pins) with the 4 leds, pot, mclr button and nice little prototype area for extra goodies, but they no longer make those ;( Also have used the Olimex PIC boards, which have a much larger prototype area. The Olimex boards have a DB9 and separate TX, RX pinouts that can be used to connect a USB to TTL serial adaptor which is always nice.

     
  • Mario Zandel

    Mario Zandel - 2018-02-28

    @kent_twt, good thinking on the port interrupts, especially being able to power down. I odered an Explorer 8 dev board yesterday at 4p.m. It was sitting on my doorstep when I got home today. Gotta love RSonline, and half the price of Ebay! Need to do some reading now to get it configured. Then I can try some of the ideas you have all come up with.
    Thanks everyone :D
    Marz.
    P.S i just saw the way to add photos. This is what I mean by not much room in the poles. This was my first version with a DIP8 Picaxe

     
  • kent_twt4

    kent_twt4 - 2018-02-28

    Very cool. I like the battery holder (18350 lithium?) part. Reminds me, I need to finish my 3d printer that's gathering dust.

    EDIT: If lico battery? do you use a tp4056 or the micro controller to charge?

     

    Last edit: kent_twt4 2018-02-28
  • Mario Zandel

    Mario Zandel - 2018-02-28

    @kent I have actually upgraded to 18650`s in the prototypes. A bit more power in reserve. I made all the battery holders on my milling machine. A lot cheaper and neater in a small area. The big circuit board under the aerial and above the batteries is all battery management. If I was smart enough it would be nice to incorporate it all in one nice big PIC if it was possible, as those boards have proven to be a bit unreliable.
    Marz.

     
  • kent_twt4

    kent_twt4 - 2018-02-28

    Huh, you have seen the little tp4056 boards, right? like https://www.fasttech.com/p/1585501
    Although charging at 1A might need a little heat sink. I have tested with mini solar panel(s) and it worked pretty good. Or maybe that is what you are using now?

    To replace the battery charger module, then need to go with a PIC like the 16f1783 that I used with a solar battery charger plus data logger project. The 16f1783 has a couple of op amps that would be useful in controlling battery charge using a CC/CV scheme.

     

    Last edit: kent_twt4 2018-02-28
  • Mario Zandel

    Mario Zandel - 2018-02-28

    @kent nice work! The battery module used charges 3 batteries in series. It has leds to show battery levels as well. But it is a large board to put in a small space.
    Marz

     
  • kent_twt4

    kent_twt4 - 2018-02-28

    Oh, the three batteries in series complicates things. Have not tried that. Anobium and others have hammered out the differential adc for GCB and devices like the 16f1783 , see HELP. If there is a will I am sure there is way forward. Development time versus off the shelf.

     
  • Mario Zandel

    Mario Zandel - 2018-02-28

    @kent, this whole project started with a simple voltage divider and has morphed into a much bigger and smarter idea. The first prototype was about revision 20. I've learned that a lot of complicated stuff makes something look simple.
    Marz

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.