Announcement

Collapse
No announcement yet.

Cow PI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I found a 1.8" color display for $5.19 shipped from Hong Kong!

    http://www.ebay.com/itm/141109430611...84.m1439.l2649

    You talk to it via SPI which is fairly simple to do in Basic. Here's the init code for Fast Master mode;

    'Set SPI pin directions
    dir PORTC.5 out
    dir PORTC.4 in
    dir PORTC.3 out


    'Set SPI Mode to master, with fast clock

    Set SSPCON1.SSPEN Off 'Turn off SPI (Prevents any weird glitches during setup)
    Set SSPSTAT.SMP Off 'Set clock pulse settings
    Set SSPSTAT.CKE Off 'Data write on rising (idle > active) clock (CPHA = 1)
    Set SSPCON1.CKP Off 'Clock idle low (CPOL = 0)
    Set SSPCON1.SSPM3 Off 'Select master mode and fast clock
    Set SSPCON1.SSPM2 Off
    Set SSPCON1.SSPM1 Off
    Set SSPCON1.SSPM0 Off
    Set SSPCON1.SSPEN On 'Enable SPI

    Then a simple subroutine will send a byte of data;
    ' SendToScreen (OutData, InData) Simultaneously send and receive a SPI byte


    Sub SendToScreen (In ScreenData, Out ScreenData)

    'Clear WCOL
    Set SSPCON1.WCOL Off

    'Put byte to send into buffer
    'Will start transfer
    SSPBUF = SPITxData

    'Read buffer
    'Same for master and slave
    Wait While SSPSTAT.BF = Off
    SPIRxData = SSPBUF
    Set SSPSTAT.BF Off

    End Sub

    We just have to figure out what to send! I imagine a graphical setup where
    you can adjust the pulse widths and spacing on the screen as line drawings...

    I'm trying to juggle the pins around and allow for the future to have 2 pairs of receiver pulses and 2 Ground Balance pulses
    as well as the analog inputs to possible sample the demodulated data.

    We need 5 pins for the initial pulses (TX, Damping, First, Second and Gnd Bal) and 3 more for future expansion (First2, Second2 and Gnd Bal2). So we'll use Port D for all 8 pulses.

    The SPI for the LCD needs most of Port C.

    We'll use A0 - 2 for Analog inputs for 3 channels and E0 - 3 for the other 3.
    A0 =First
    A1 = Second
    A2 = Gnd Bal
    E0 = First2
    E1 = Second2
    E2 = Gnd Bal2

    And we still have all of Port B for fun stuff like LED's and Rotary Encoders!
    Attached Files
    Last edited by Silver Dollar; 12-27-2013, 10:07 PM. Reason: Add Schematic

    Comment


    • #17
      Well it seems the SPI lines are in a different place on the 44 pin chip so I drew up a new schematic with them correctly shown.
      There's a lot of pitfalls working with these chips. Even with Megs of documentation it's tricky to find all the info you need. The pins
      sometimes have 4 or 5 different functions and there is no clear cross reference on where each pin name is used. I think if you have
      been working with them from the start there is some historical knowledge that helps...
      Attached Files

      Comment


      • #18
        So our design is coming together. Here is a list of the pins we will use on the PIC 18F4550

        ' Use Port E0 - 2 for AD's
        ' Port D0 - 7 for TX, Damping, First, Second, Ground Balance and First2, Second2, Ground Balance2 Pulses
        ' Port A0 - 2 for First, Second, and Ground Balance Analog Inputs
        ' Port E0 - 2 for First2, Second2, and Ground Balance2 Analog Inputs


        ' SDI pins
        ' PORT A.3 = CS
        ' PORT A.4 = D/C
        ' PORT A.5 /SS - No SS on LCD?
        ' PORT B.0 = SDI
        ' PORT B.1 = SCK
        ' PORT C.7 = SDO - No Dout on LCD?


        ' Roto Switch Pins
        ' PORT B.2 = Roto Switch Can use Interupt to Signal Data Change
        ' PORT B.3 = Phase A
        ' PORT B.4 = Phase B

        We may have trouble with the timing when we try to digitize those analog channels but I have some 30F2020's that could be pressed into
        service as data gatherer's. The 18F4550 might end up as the user interface chip in the final design.

        The screen is basically 128x64 pixels 18 bits deep. There are no character functions and even no easy way to clear the screen!
        We'll have to create our own character set as well as a cursor function. The pixel data is 12, 16, or 18 bits. 16 might be easiest
        to implement as it's just 2 bytes, though the data is 5 - 6 - 5 (RGB).

        I think to start we'll use a fixed screen and just update the changing value;
        Click image for larger version

Name:	CowPIScreen.png
Views:	1
Size:	12.5 KB
ID:	338767

        The cursor will move between the various numbers and allow changing them. The rest of the screen will remain fixed. Later we can get more creative.

        Comment


        • #19
          You may be interested in this thread
          http://www.geotech1.com/forums/showt...ntrols-and-LCD

          Comment


          • #20
            Thanks for the tip but that guy didn't show his code. I'd like to be able to experiment
            with the code and see if I can make it better. Here's a schematic of a possible way to

            use the 30F2020 as a digitizer. It has the horsepower but you need to code it in C or
            assembler. I might be able to use some code from the 30F3012 source for the UNIPI.

            It's just the hairy fast ADC and lockin code so it should be easy right? Well I'm glad we
            don't have a timetable to meet. Anyway we can get it running now by just sending some
            pulses to the Hammerhead board. That code was relatively easy.

            I downloaded and installed Freebasic today to allow me to test the LCD code on my local
            machine to tweak locations and colors and such. I have some code but so far nothing
            shows up on the screen. Probably a problem with the color setting or something...
            Attached Files

            Comment


            • #21
              Hi, there is no code, but I thought you may have been interested in how the timings were displayed.

              Comment


              • #22
                Here's some code I've been working on. I couldn't find any ready made stuff so I had to write my own!
                I have a 5x7 font to draw on the screen pixel by pixel. I have an 18 bit to 16 color array. (all colors are
                18 bit but I use a fixed set of 16). I can draw lines and boxes.

                There's still a lot of little questions that will have to wait until I have all the hardware here (like is it 130
                or 127 pixels and how does the set row and set column work?).

                Happy New Year to everyone. I hope this year is a good one for all!
                Attached Files

                Comment


                • #23
                  Well that code had some bugs. I compiled it today here are the new files.

                  It compiles but may still not work. I'm trying to emulate it in Freebasic.

                  I hope some of my goodies for this project come in tomorrow!
                  Attached Files

                  Comment


                  • #24
                    I've been figuring out some programming issues. I have a character set and
                    some drawing routines and now am working on Menu's. I'm not sure I like the
                    way the Menu came out. The screen is smaller than I thought (see picture).

                    Lucky it is winter and not much else to do!

                    I did recover some laptop batteries yesterday. They use 18650 type batteries which are 4.2v fully charged.
                    I took apart 4 battery packs and ended up with 34 batteries. I sent for some single battery chargers for only $1 each!;
                    http://www.ebay.com/itm/400635991300...84.m1439.l2649

                    I'll charge them all up and see which ones are bad. Usually 2 or 2 go bad and the pack doesn't work
                    anymore. If the charge up to 4.2v they should be OK.

                    The MD pack will have to be 3 (11V) or 4 (16V) cells. You have to break the connections to charge using
                    these single cell chargers that makes it easier to make sure the cells match voltage wise.

                    The plan is to use a 5v 4A - 5A power supply and tie all 4 chargers to it with each wired to a separate
                    battery holder; http://www.ebay.com/itm/380676071451...84.m1439.l2649

                    Multicell packs need to be "Balanced" and tend to fail when one cell becomes mismatched so charging individual
                    ones makes sense!

                    Note: Use extreme care when working with these batteries as if you short them out they will produce massive
                    current and get hot enough to start a fire! You have to cut the connections carefully to avoid shorts.
                    Attached Files

                    Comment


                    • #25
                      Well the software is progressing. I have completed the Video routines except for
                      some SPI clocking bit settings. It's not clear how those need to be set. I'm
                      embedding the SPI routines in my code to be sure they don't change and to have
                      control over them. We don't receive any data back so can tweak the subroutine
                      so as to not need the extra byte sent to it.

                      The main routine saves program data to EEPROM and reads it back (though exact
                      data to save and retrieve may change). The menu's have to be fleshed out. They will
                      work similar to the menu.inc included. A string will embed all the words for a given
                      menu and then will be accessed via the Right, Left and Mid string commands. A separate
                      array will hold the locations.

                      The range of pulse width and padding can be extended to 65535 with a word variable but
                      for now they are limited to 255.

                      I'm reading the new thread on ground balancing and wondering how to implement it in
                      this design? If we had the data sampled we could explore different ways to do it. The
                      Kingfisher design tried to use this PIC and sample but was abandoned due to not enough
                      speed to do it...

                      I've seen a patent on some sort of feedback to subtract the ground. I wonder if we
                      couldn't do some sort of manual ground balance by just setting an analog voltage to be
                      added/subtracted to the integrator signal? We could even do that with an old ordinary pot...
                      Attached Files

                      Comment


                      • #26
                        I've been fine tuning the software. I am trying to do some "Bit Blasting" to make the menu's fast.
                        I'm still trying to figure out which mode the SPI should run in. I think mode 0 or 3.

                        I disassembled 4 old cell phones today to see if I could salvage a display or keyboard for this
                        project but it doesn't look too promising. The connectors are tiny and the keyboards don't even
                        have a visible connector...

                        The display has a SD card reader built in so I thought we might be able to use it for bit map data
                        and possibly fonts. I don't want to write a complete file system handler but might try some sort of
                        raw data storage. Not much info out there on implementing that. Most people go straight to C and
                        a huge library. There has got to be a way to write the raw data as if you were formatting the card...

                        Comment


                        • #27
                          We one gotcha is that the SD cards are 3.3v and the PIC is 5v so some level translating is in order.
                          I found a hex editor that allows you to write to the SD card while in the computer.
                          http://mh-nexus.de/en/hxd/

                          I also won a 512mb card on Ebay for $3.50, we don't need much storage and I was looking for cheap!
                          We're going to talk to it via SPI so we have to avoid the micro SD's as they are not guaranteed to work
                          in SPI mode.

                          Comment


                          • #28
                            Well after a brief sojourn I'm back on this project. I got my Hammer Head mostly built up and tested the power supply and clocks.
                            The plan is to make it work as a Hammer Head then modify it to use the 18F4550 board for control. I'm forming an idea to use the
                            4550 as the interface chip and add some DSP's to get some fast samples. I also got the rotary encoders and the display and SD card.
                            I still need to mod the 4550 board to add the in circuit programming connections. The pins are tiny so I need a new tip for my iron
                            to do that. I do a lot of soldering at my new job so maybe I can bring it to work and pop those 5 wires on...

                            I also picked up a Chance PI board and I'm trying to disassemble the code for that project to do a little tweaking. That's going to
                            take some time though so don't hold your breath.

                            The attached picture is the project so far. I hope to get it all soldered together and start programming some code into it soon!

                            Attached Files

                            Comment


                            • #29
                              After a bit of contemplation I've decided to take this project in a different direction.

                              It seems the fancy display is probably not very useful out in the field. Most people
                              want better audio to help in identifying targets. Also less adjustments are better as
                              you end up like my brother in law who drives around looking at his fish finder more
                              than he actually fishes.

                              So we need to determine what we need. I'm going to back off from the 30F2020
                              DSP's for now to concentrate on getting a working detector before spring!

                              We can still use the 4550 board but change the user interface a bit. The Hammerhead
                              (from Silverdog) brings 3 pots to the front panel Threshold, TX Width, and Main Delay.

                              I'm not sure how often we might want to change the TX width. I'm thinking we could
                              have a Low Range/ High Range switch. That would leave Threshold and Main Delay.
                              We could have auto adjusting RX widths too.

                              Threshold would be like sensitivity and main delay would be for adjusting what size
                              target you are looking for. I wonder how we could add more info to the audio output?

                              I was reading a patent last night and they used a 60 us TX width and 600 hz rate.
                              And 30 us wide RX's 150 us apart and the main delay started at the flyback decay
                              and could be adjusted 100 us out.

                              So we could use these numbers to start with. Maybe 50 / 100 us ranges for TX width
                              and 10 / 30 us for RX widths (depending on range).

                              So our front panel controls will be a High/Low Range switch and a Threshold pot connected
                              to R31 on the Hammerhead board, and a rotary encoder to adjust main delay and a power
                              switch. Even simpler would be to use the push switch on the encoder to change ranges with
                              a LED to indicate current range.

                              Comment


                              • #30
                                Hey Silver Dollar,

                                I will be keeping tabs on this thread with much interest, thanks for letting me know. I was looking at your code but it was greek to me...lol
                                guess I'm to use to the picaxe grade school programming I guess


                                Do you have any left over pins and if so how many and have you thought about using them for a frequency shifter/switch?


                                When I had my minelab eureka gold I liked being able to switch frequency when I would change out coils and have wondered why no other (at least I haven't seen any yet) detectors don't use that tech other than minelab.. I was thinking it could be implemented on a home brew if using a micro controller, in which case you are and it is basically what I had in mind when I thought I could use the picaxe to start my little project. Having 2 frequencies to use would be a nice option/addition.


                                For my project or idea, I just really wasn't sure where to start and what pic I would really need to start with. I think I could start with an 18 pin (18x or 18m2) for a "basic get started" setup then go from there.


                                I really did like the idea of your lcd display, I'm a visual kind of person so I like to have the extra feature of something visible to back up what I think I am hearing. I found a simple led vu meter and added it to my surf pi, it does not need external voltage and will work within the circuits audio, so when it is soldered in parallel with the headphone any signal that the detector picks up lights the leds in a range, the stronger the signal, the more leds light up and vise versa. I like it better than a needle type. Maybe that could be something you could add/implement when the time comes.


                                Anyways, thank you for sharing what you have come up with so far, I look forward to seeing your progress and the end result.

                                Geo

                                LED VU Meter - http://www.electronics123.com/kits-a...AY-10-LED.html

                                OLED display - http://www.picaxestore.com/index.php...s/axe134y.html (not sure if this could be useful to you)
                                Attached Files
                                Last edited by geoscash1; 03-24-2014, 03:46 PM. Reason: forgot link

                                Comment

                                Working...