Page 3 of 10 FirstFirst 123456 ... LastLast
Results 25 to 36 of 110

Thread: PIC based DRO

  1. #25
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0

    Thanks!

    Ok cool! Thank you both of you for the info. That's basically what I needed and I don't know how I overlooked the necessity of the LEDS for the using clock and data to set the mode and zero.

    I do have another question though... Where did you source the -1.5v for ground? The scale's ground?

    Sorry if this is obvious, I'm still learning and I gotta start somewhere


  2. #26
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    If you squint at my picture long enough you should be able to make out a 5v regulator with a resistor + Red LED giving about 1v5 above the regulator's 0v, this is taken to the common ground so giving -1v5 (regulator 0v and PIC Vss) & +3v5 (reg +5v and PIC Vdd) from a floating PSU input.
    Where did you source the -1.5v for ground? The scale's ground?
    No, the scales ground (battery +ve) is the same as the PC's ground i.e. Earth potential, the -1v5 is the scale's power supply input (battery -ve).
    Bill


  3. #27
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by BillTodd View Post
    If you squint at my picture long enough you should be able to make out a 5v regulator with a resistor + Red LED giving about 1v5 above the regulator's 0v, this is taken to the common ground so giving -1v5 (regulator 0v and PIC Vss) & +3v5 (reg +5v and PIC Vdd) from a floating PSU input.


    No, the scales ground (battery +ve) is the same as the PC's ground i.e. Earth potential, the -1v5 is the scale's power supply input (battery -ve).
    Oh my... I appologize. I was too busy looking at the code and I didn't scroll down far enough to see the picture you attached. I was referencing the diagram on your site.

    Almost time to go home so I can work on something fun.


  4. #28
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0

    ugh

    Well after some extensive messing around it seems that I need to learn assembly... I've been programming these little chips for awhile now using MikroC and it's worked quite well until now. Unfortunately, it looks as though the code just doesn't run fast enough to pick up those 90khz signals unless it's done in assembly. Simply reading the value of COUT is taking serval intructions (when you look at the assembly version), which just isn't necessary.

    No biggy Knowing assembly should make using the datasheets much simpler!

    Be back soon!


  • #29
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    Well after some extensive messing around it seems that I need to learn assembly
    PIC assembler is easy only 35(?) instructions (it's the carry that always throws me - is it set or reset after subtraction???? - catches me out every time!)

    I don't think HLLs like 'C' are ideal for programming these little controller chips. PICs in particular benefit greatly from careful optimisation even in when writing in assembler.

    Is it possible to embed and call assembler routines in your version of C?
    Bill


  • #30
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0
    I can place assembly directly into the C code and have done that with some minor things... However, I'm not certain how to use them together in a looping or conditional situation.


  • #31
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    If you want to just concentrate on the convert and display device, and are happy using async serial instead of I2C, I could let you have a copy of my obect code and a run down of the interface protocol? (may even have the board design somewhere)
    Bill


  • #32
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by BillTodd View Post
    If you want to just concentrate on the convert and display device, and are happy using async serial instead of I2C, I could let you have a copy of my obect code and a run down of the interface protocol? (may even have the board design somewhere)
    Actually that would be really nice... I've been spending some time the last few days getting a grasp on programming the PIC's in assembly. It's really quite interesting. I probably won't use your code directly and as more of a guideline. Not because I think I could do it better, but because I still want to learn assembly for these chips.

    If you have a larger picture of the scale schematic you posted that would help quite a bit.

    Thanks again for all of your help.


  • #33
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    I've been spending some time the last few days getting a grasp on programming the PIC's in assembly.
    Like most things, you have to get your knowledge up to a 'critical mass' Once you can get the thing to compile you're pretty much there [these days I find the 'mass' evaporates faster and faster - I have to top-up every time I revisit it!]

    won't use your code directly and as more of a guideline.
    It might just confuse you (I learnt 'assembly' years ago programming Z80s with simple assemblers, so I don't use a fraction of the newer assembler/compiler's capabilities)

    The source should open with MPLab 8 or later.

    Keep us informed of your progress
    Attached Thumbnails Attached Thumbnails PIC based DRO-multichannel_reader.pdf  
    Attached Files Attached Files
    Bill


  • #34
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0

    YAY!

    Alright so I've made some pretty decent progress!

    After going through the typical blinking LED, input, etc. stuff I finally decided to take a crack at reading this signal. To my surprise, my first try worked!

    I decided my first step should be simply determining if the PIC was reading the signal correctly. This was done by turning a pin on when it sensed the clock was high and turning it off once the clock went back low. This turned out to be surprisingly simple and FAST... Here is the little bit that does that portion:

    Code:
    RL1		btfss	CMCON,COUT	;wait for clock high
    		GOTO RL1
    		XORWF	GPIO,5		;toggle GP5
    RL2		btfsc	CMCON,COUT	;wait for clock low
    		GOTO RL2		
    		XORWF	GPIO,5		;toggle GP5
    		GOTO RL1
    I then connected one channel of my oscilloscope to GP5 on the PIC and one channel to the scales output (which was also going into the pic).

    Check out the result in the attached image. The red line is the output from the PIC and the blue line is the output from the scale... They were both being read at the same time.

    I would like to add that I could NOT get this to work correctly using MikroC... Nothing against it, but the speed difference is quite obvious.
    Attached Thumbnails Attached Thumbnails PIC based DRO-scale_vs_pic.jpg  


  • #35
    Registered
    Join Date
    Jul 2009
    Location
    US
    Posts
    17
    Downloads
    0
    Uploads
    0

    Quick update...

    One little change to that code... GPIO,5 should actually be GPIO,1

    Code:
    RL1		btfss	CMCON,COUT	;wait for clock high
    		GOTO RL1
    		XORWF	GPIO,1		;toggle GP5
    RL2		btfsc	CMCON,COUT	;wait for clock low
    		GOTO RL2		
    		XORWF	GPIO,1		;toggle GP5
    		GOTO RL1


  • #36
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    You're a fast learner

    Be aware there pitfalls if you talk to the GPIO using those infamous read-modify-write instructions sometimes you get away with it sometimes you don't (there's full explanation on the microchip site).
    Bill


  • Page 3 of 10 FirstFirst 123456 ... LastLast

    Similar Threads

    1. Is water based
      By CNCadmin in forum Safety Zone
      Replies: 44
      Last Post: 10-15-2010, 03:27 PM
    2. Need help with CNC UK based
      By ciscoe in forum Europe Club House
      Replies: 1
      Last Post: 07-21-2008, 07:03 AM
    3. Convert to PC based
      By Arcticfox46 in forum CNC Wood Router Project Log
      Replies: 4
      Last Post: 08-10-2007, 09:05 AM
    4. Used CMM based DIY router?
      By biomed_eng in forum DIY CNC Router Table Machines
      Replies: 1
      Last Post: 10-16-2006, 09:52 PM
    5. dos based cnc software
      By flyingmike in forum Computers and Networking
      Replies: 14
      Last Post: 11-25-2005, 02:29 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.