Shop OBEX P1 Docs P2 Docs Learn Events
C3, A/D, Femtobasic problem(?) — Parallax Forums

C3, A/D, Femtobasic problem(?)

sidecar-racersidecar-racer Posts: 82
edited 2011-12-25 00:07 in Propeller 1
Working on same project, "C3 and SD card".
Decided to use the drivers with the two versions of FemtoBasic from Parallax website for C3.
1. David Betz
2. Mike Green
The first version would hang when an ADC call was made using fsrwfemto.spin.
The second version returned un-related numbers using isxspi.spin.

So, I loaded the associated FemtoBasic and got the same problems;
1. PRINT ADC[0,0] would hang C3
2. PRINT ADC[0,0] would return from -65 to -1536 erratically (never same value twice) and interaction between channels.
(Same numbers as isxspi.spin)

The C3 A/D demo runs just fine with values of 0 to 4095 as expected.

Am I dealing with a bug(s) in FemtoBasic drivers or perhaps a problem with my C3?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-25 15:53
    The problem is probably in the driver. I'll check it out. It may take a few days.
  • David BetzDavid Betz Posts: 14,516
    edited 2011-11-26 06:51
    I don't think the driver that I converted for the C3 even tries to handle the ADC chip. Sorry!
  • sidecar-racersidecar-racer Posts: 82
    edited 2011-11-26 09:41
    Thank you very much for prompt response. My project is coming along well especially with all the help that is available here.
    I hope to do a web presentation next year (we're located near Rocklin)
    Rick & Nida Murray
  • StephenMooreStephenMoore Posts: 188
    edited 2011-11-28 21:32
    I have experienced the same problem with the C3.

    I have written a datalogging program and verified its use with the SRAM and the ADC. However, I have never gotten the program to work with any of the recommended SD drivers: FemtoBasic, FSRW, SDFATEngine, LaMothe code, SD-MMC_FATEngine... you name it. I have spent many hours trying different drivers, configurations, timing schemes etc. I finally gave up be cause it just didn't seem worthwhile anymore.

    It's frustrating because I had high hopes for the C3 as a versatile little tool but it has too many idiosyncracies for me to try to use it as a datalogger. Even though it has a tremendous SRAM buffer and huge SD capability.

    If anyone works out the IO conflicts I would love to try out the code.

    SM
  • sidecar-racersidecar-racer Posts: 82
    edited 2011-11-29 11:20
    Hopefully this thread can get some answers. I too have a datalogger program, used the SD-MMC_FATEngine that was modifed to do SD card profiling on the C3. It worked fine to create an CSV file with records of my revolution timers, time clock, etc. Main loop at 100ms. As long as I did not attempt to access A/D routines.
    Rick
  • KyeKye Posts: 2,200
    edited 2011-11-29 12:34
    I did not design my code to work with the C3 nor do I have a C3. Sorry, about the SD-MMC_FATEngine. I don't know how the ADC uses the bus but I guess everything just doesn't work nicely with each other.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-29 12:59
    The C3 version of FemtoBasic was made by modifying the low level SD card driver to work with the C3 SPI selection hardware, adding a modified SRAM and Flash driver, then adding ADC access. All of the low level access was designed to work with each other. I did a lot of testing of the SRAM, Flash, and SD card drivers, but only a little testing for the ADC driver since it mostly uses the low level SRAM / Flash / ADC driver. I should be able to start looking at it tomorrow.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-10 20:49
    It took longer than I thought. The error was simple and I don't understand why I didn't catch it earlier. It was in the Winbond_Driver for the C3. The byte order of the value returned for the ADC was wrong. Attached is a corrected version. I'll clean up the changes and post them to the ObEx in the next day or two. Sorry.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-10 21:42
    Here's a corrected version of FemtoBasic using the Sphinx I/O routines as posted to the C3 FTP server. I'll post a corrected version there after doing some more testing.
  • sidecar-racersidecar-racer Posts: 82
    edited 2011-12-11 09:38
    Thank you, Mike. These forums are great for the noobie like me.
    Rick
  • StephenMooreStephenMoore Posts: 188
    edited 2011-12-11 22:17
    Hey great Mr Green.

    I will have a crack at my data logger again with your latest routines. But what is the C3 FTP site? I was going to suggest that C3 specific software listed in the OBEX (if in fact there is any) have its own C3 folder.

    Thanks for your dedication...

    SM
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-11 22:21
    There's a link to an FTP site for C3 programs on the Parallax webstore page for the C3 board.
  • StephenMooreStephenMoore Posts: 188
    edited 2011-12-17 16:03
    OK. I am trying to wade through the program structure of Sphinx Basic and having a bit of a tough time.

    Here are the objects I am referencing in my main program:
     math       : "FloatMath.spin"
     mathStr    : "FloatString.spin"
     term_vga   : "VGA_Text_010.spin"                   ' instantiate VGA terminal driver
     kbd        : "keyboard_010.spin"                   ' instantiate keyboard driver
     sdfile     : "sxfile.spin"
     sxfs       : "sxfs.spin"    
    

    Is this correct to access the SD driver for the C3?

    If it is do I simply open a file and begin writing with:
    DAT   myStr     byte    "Test text.",  0
    
     sdfile.Open(String("TEST"), "W" )
     sdfile.Write(myStr, strsize(myStr)) 
     sdfile.Close
    
    

    Because the C3 keeps locking up like it did when I tried the AD_INIT with any of the other SD drivers.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-17 17:27
    I can't tell what you're using. There are two versions of FemtoBasic that use the Sphinx I/O routines. One version, called FemtoBas.spin, uses the Sphinx I/O routines, but is entirely self contained. It first initializes the Sphinx I/O routines including the display, keyboard, and SPI drivers, then goes on to use the drivers. The other version, called FemtoSph.spin, uses the Sphinx I/O routines and can only run under Sphinx as modified for the C3. It assumes that the Sphinx I/O routines are already initialized. The archive I posted in #10 contains both of these. There's a 3rd version of FemtoBasic for the C3 that I posted in #9 which is based directly on the FemtoBasic in the ObEx. It uses a modified version of Rokicki's SD card driver as well as a modified version of my SPI (Flash, SRAM, and ADC) driver. If you're not going to run things under Sphinx, I suggest you use the 3rd version.
  • StephenMooreStephenMoore Posts: 188
    edited 2011-12-25 00:07
    Finally I got it to work (everything on the C3).

    If anyone is still interested. I know this is a bit redundant but it is such a hurdle for me I thought I should publish!

    I have used fsrw.spin for SD access (the C3 SPI version) along with LaMothe's simple routines for access to the ADC, SRAM, and Flash RAM .

    It at least seems to be functioning as I can read the data files created on the SD with my Excel spreadsheet.

    So, I now have a data log device (the C3) that I plan on streamlining for future use. One of my colleagues at work wants a low cost system to remotely record accelerometer measurements over an extended period of time and this is a good candidate. We may even incorporate an Xbee system for log file retrieval.

    Merry Christmas,

    SM
Sign In or Register to comment.