Raspberry Pi 4 7i90 on Mojo V3 board BSPI

More
05 Jun 2021 17:11 #211233 by rbobey1989
hello everyone, sorry in advance if I am not in the correct category, after doing some tests with rpi4 and mojo V3 running hostmot for 7i90, I thought that I could write a driver for some AS5048 encoders that I have at home, but I am somewhat lost , I have looked for information in:
- HAL basics
- The HAL Component Generator
- mesa_7i65.comp
and I have managed to understand some things but I have a sea of doubts.

To do some tests I first loaded from halcmd hostmot and hm2_rpspi and this is the output:
halcmd: loadrt hostmot2
Note: Using POSIX realtime
hm2: loading Mesa HostMot2 driver version 0.15
halcmd: loadrt hm2_rpspi
hm2/hm2_7i90.0: Low Level init 0.15
hm2/hm2_7i90.0: created Buffered SPI function hm2_7i90.0.bspi.0.
hm2/hm2_7i90.0: created Buffered SPI function hm2_7i90.0.bspi.1.
hm2/hm2_7i90.0: 72 I/O Pins used:
hm2/hm2_7i90.0: IO Pin 000 (P1-01): IOPort
hm2/hm2_7i90.0: IO Pin 001 (P1-03): IOPort
hm2/hm2_7i90.0: IO Pin 002 (P1-05): IOPort
hm2/hm2_7i90.0: IO Pin 003 (P1-07): IOPort
hm2/hm2_7i90.0: IO Pin 004 (P1-09): IOPort
hm2/hm2_7i90.0: IO Pin 005 (P1-11): IOPort
hm2/hm2_7i90.0: IO Pin 006 (P1-13): IOPort
hm2/hm2_7i90.0: IO Pin 007 (P1-15): IOPort
hm2/hm2_7i90.0: IO Pin 008 (P1-17): IOPort
hm2/hm2_7i90.0: IO Pin 009 (P1-19): IOPort
hm2/hm2_7i90.0: IO Pin 010 (P1-21): IOPort
hm2/hm2_7i90.0: IO Pin 011 (P1-23): IOPort
hm2/hm2_7i90.0: IO Pin 012 (P1-25): IOPort
hm2/hm2_7i90.0: IO Pin 013 (P1-27): IOPort
hm2/hm2_7i90.0: IO Pin 014 (P1-29): IOPort
hm2/hm2_7i90.0: IO Pin 015 (P1-31): IOPort
hm2/hm2_7i90.0: IO Pin 016 (P1-33): IOPort
hm2/hm2_7i90.0: IO Pin 017 (P1-35): IOPort
hm2/hm2_7i90.0: IO Pin 018 (P1-37): IOPort
hm2/hm2_7i90.0: IO Pin 019 (P1-39): IOPort
hm2/hm2_7i90.0: IO Pin 020 (P1-41): IOPort
hm2/hm2_7i90.0: IO Pin 021 (P1-43): IOPort
hm2/hm2_7i90.0: IO Pin 022 (P1-45): StepGen #2, pin Direction (Output)
hm2/hm2_7i90.0: IO Pin 023 (P1-47): IOPort
hm2/hm2_7i90.0: IO Pin 024 (P2-01): StepGen #2, pin Step (Output)
hm2/hm2_7i90.0: IO Pin 025 (P2-03): IOPort
hm2/hm2_7i90.0: IO Pin 026 (P2-05): StepGen #1, pin Direction (Output)
hm2/hm2_7i90.0: IO Pin 027 (P2-07): IOPort
hm2/hm2_7i90.0: IO Pin 028 (P2-09): StepGen #1, pin Step (Output)
hm2/hm2_7i90.0: IO Pin 029 (P2-11): IOPort
hm2/hm2_7i90.0: IO Pin 030 (P2-13): StepGen #0, pin Direction (Output)
hm2/hm2_7i90.0: IO Pin 031 (P2-15): IOPort
hm2/hm2_7i90.0: IO Pin 032 (P2-17): StepGen #0, pin Step (Output)
hm2/hm2_7i90.0: IO Pin 033 (P2-19): Buffered SPI Interface #0, pin Serial Out (Output)
hm2/hm2_7i90.0: IO Pin 034 (P2-21): Buffered SPI Interface #0, pin CS0 (Output)
hm2/hm2_7i90.0: IO Pin 035 (P2-23): Buffered SPI Interface #0, pin Serial In (Input)
hm2/hm2_7i90.0: IO Pin 036 (P2-25): Buffered SPI Interface #0, pin CS1 (Output)
hm2/hm2_7i90.0: IO Pin 037 (P2-27): Buffered SPI Interface #0, pin Clock (Output)
hm2/hm2_7i90.0: IO Pin 038 (P2-29): IOPort
hm2/hm2_7i90.0: IO Pin 039 (P2-31): IOPort
hm2/hm2_7i90.0: IO Pin 040 (P2-33): IOPort
hm2/hm2_7i90.0: IO Pin 041 (P2-35): IOPort
hm2/hm2_7i90.0: IO Pin 042 (P2-37): IOPort
hm2/hm2_7i90.0: IO Pin 043 (P2-39): IOPort
hm2/hm2_7i90.0: IO Pin 044 (P2-41): IOPort
hm2/hm2_7i90.0: IO Pin 045 (P2-43): IOPort
hm2/hm2_7i90.0: IO Pin 046 (P2-45): IOPort
hm2/hm2_7i90.0: IO Pin 047 (P2-47): IOPort
hm2/hm2_7i90.0: IO Pin 048 (P3-01): IOPort
hm2/hm2_7i90.0: IO Pin 049 (P3-03): IOPort
hm2/hm2_7i90.0: IO Pin 050 (P3-05): IOPort
hm2/hm2_7i90.0: IO Pin 051 (P3-07): IOPort
hm2/hm2_7i90.0: IO Pin 052 (P3-09): IOPort
hm2/hm2_7i90.0: IO Pin 053 (P3-11): IOPort
hm2/hm2_7i90.0: IO Pin 054 (P3-13): IOPort
hm2/hm2_7i90.0: IO Pin 055 (P3-15): IOPort
hm2/hm2_7i90.0: IO Pin 056 (P3-17): IOPort
hm2/hm2_7i90.0: IO Pin 057 (P3-19): IOPort
hm2/hm2_7i90.0: IO Pin 058 (P3-21): IOPort
hm2/hm2_7i90.0: IO Pin 059 (P3-23): IOPort
hm2/hm2_7i90.0: IO Pin 060 (P3-25): IOPort
hm2/hm2_7i90.0: IO Pin 061 (P3-27): IOPort
hm2/hm2_7i90.0: IO Pin 062 (P3-29): IOPort
hm2/hm2_7i90.0: IO Pin 063 (P3-31): IOPort
hm2/hm2_7i90.0: IO Pin 064 (P3-33): IOPort
hm2/hm2_7i90.0: IO Pin 065 (P3-35): IOPort
hm2/hm2_7i90.0: IO Pin 066 (P3-37): IOPort
hm2/hm2_7i90.0: IO Pin 067 (P3-39): IOPort
hm2/hm2_7i90.0: IO Pin 068 (P3-41): IOPort
hm2/hm2_7i90.0: IO Pin 069 (P3-43): IOPort
hm2/hm2_7i90.0: IO Pin 070 (P3-45): IOPort
hm2/hm2_7i90.0: IO Pin 071 (P3-47): IOPort
hm2/hm2_7i90.0: registered


So far so good, so I have modified the mesa_7i65.comp controller a bit to only configure the 1 channel with two CS but it produces the following errors:

halcmd: loadrt threads name1 = servo-thread period1 = 1000000

halcmd: loadrt rtAS5048 bspi_chans = hm2_7i90.0.bspi.0
hm2 / hm2_7i90.0: The selected write channel (1) on bspi instance hm2_7i90.0.bspi.0.
Has not been configured.
hm2 / hm2_7i90.0: The selected write channel (1) on bspi instance hm2_7i90.0.bspi.0.
Has not been configured.
There have been 2 errors during TRAM allocation setup, quitting
rtAS5048: rtapi_app_main: Invalid argument (-22)
<stdin>: 4: waitpid failed / usr / bin / rtapi_app rtAS5048
<stdin>: 4: / usr / bin / rtapi_app exited without becoming ready
<stdin>: 4: insmod for rtAS5048 failed, returned -1

File Attachment:

File Name: rtAS5048.comp
File Size:2 KB


Any help will be very welcome, regards
Attachments:

Please Log in or Create an account to join the conversation.

More
05 Jun 2021 18:55 #211241 by cakeslob
Hey, sorry, I wont be able to provide assistance, Im not the best with stuff, but it piqued my interest, so I set up my mojo the other day and connected to it. Unfortunatly I loaded the wrong bitfile a few years back that has only bspi channels and no step/dir, so I have to synth a new one from ISE before I play. anyways though,
The only help I can provide is linking to my references, this guy has a lot of bspi stuff in his config, and a bunch of mojo related comps/drivers , so maybe it will help.
github.com/LinuxCNC/linuxcnc/compare/mas...op:fishybearG-master
github.com/sleepybishop/mojo_hostmot2
github.com/sleepybishop/linuxcnc_configs...r_mojo/ultimaker.hal


Are using just a breakout board for the as5048 or is it connected to one of those closed loop stepper boards?
Do you still have to do setp in hal or is it handled by the comp?

Please Log in or Create an account to join the conversation.

More
06 Jun 2021 19:26 #211328 by rbobey1989
Hello, some progress has been made, thanks to cakeslob for the references provided above, I have managed to load the controller in HAL, although I cannot make valid reads, I have made some changes in rtAS5048.comp I am attaching the file, I have changed the pins on hostmot pin.vhd for more convenience and I have removed CS1 for the first tests.

halcmd: loadrt hostmot2
Note: Using POSIX realtime
hm2: loading Mesa HostMot2 driver version 0.15
halcmd: loadrt hm2_rpspi
hm2/hm2_7i90.0: Low Level init 0.15
hm2/hm2_7i90.0: created Buffered SPI function hm2_7i90.0.bspi.0.
hm2/hm2_7i90.0: 72 I/O Pins used:
hm2/hm2_7i90.0: IO Pin 000 (P1-01): Buffered SPI Interface #0, pin Clock (Output)
hm2/hm2_7i90.0: IO Pin 001 (P1-03): Buffered SPI Interface #0, pin Serial Out (Output)
hm2/hm2_7i90.0: IO Pin 002 (P1-05): Buffered SPI Interface #0, pin Serial In (Input)
hm2/hm2_7i90.0: IO Pin 003 (P1-07): Buffered SPI Interface #0, pin CS0 (Output)
hm2/hm2_7i90.0: IO Pin 004 (P1-09): IOPort
hm2/hm2_7i90.0: IO Pin 005 (P1-11): IOPort
hm2/hm2_7i90.0: IO Pin 006 (P1-13): IOPort
hm2/hm2_7i90.0: IO Pin 007 (P1-15): IOPort
hm2/hm2_7i90.0: IO Pin 008 (P1-17): IOPort
hm2/hm2_7i90.0: IO Pin 009 (P1-19): IOPort
hm2/hm2_7i90.0: IO Pin 010 (P1-21): IOPort
hm2/hm2_7i90.0: IO Pin 011 (P1-23): IOPort
hm2/hm2_7i90.0: IO Pin 012 (P1-25): IOPort
hm2/hm2_7i90.0: IO Pin 013 (P1-27): IOPort
hm2/hm2_7i90.0: IO Pin 014 (P1-29): IOPort
hm2/hm2_7i90.0: IO Pin 015 (P1-31): IOPort
hm2/hm2_7i90.0: IO Pin 016 (P1-33): IOPort
hm2/hm2_7i90.0: IO Pin 017 (P1-35): IOPort
hm2/hm2_7i90.0: IO Pin 018 (P1-37): IOPort
hm2/hm2_7i90.0: IO Pin 019 (P1-39): IOPort
hm2/hm2_7i90.0: IO Pin 020 (P1-41): IOPort
hm2/hm2_7i90.0: IO Pin 021 (P1-43): IOPort
hm2/hm2_7i90.0: IO Pin 022 (P1-45): StepGen #2, pin Direction (Output)
hm2/hm2_7i90.0: IO Pin 023 (P1-47): IOPort
hm2/hm2_7i90.0: IO Pin 024 (P2-01): StepGen #2, pin Step (Output)
hm2/hm2_7i90.0: IO Pin 025 (P2-03): IOPort
hm2/hm2_7i90.0: IO Pin 026 (P2-05): StepGen #1, pin Direction (Output)
hm2/hm2_7i90.0: IO Pin 027 (P2-07): IOPort
hm2/hm2_7i90.0: IO Pin 028 (P2-09): StepGen #1, pin Step (Output)
hm2/hm2_7i90.0: IO Pin 029 (P2-11): IOPort
hm2/hm2_7i90.0: IO Pin 030 (P2-13): StepGen #0, pin Direction (Output)
hm2/hm2_7i90.0: IO Pin 031 (P2-15): IOPort
hm2/hm2_7i90.0: IO Pin 032 (P2-17): StepGen #0, pin Step (Output)
hm2/hm2_7i90.0: IO Pin 033 (P2-19): IOPort
hm2/hm2_7i90.0: IO Pin 034 (P2-21): IOPort
hm2/hm2_7i90.0: IO Pin 035 (P2-23): IOPort
hm2/hm2_7i90.0: IO Pin 036 (P2-25): IOPort
hm2/hm2_7i90.0: IO Pin 037 (P2-27): IOPort
hm2/hm2_7i90.0: IO Pin 038 (P2-29): IOPort
hm2/hm2_7i90.0: IO Pin 039 (P2-31): IOPort
hm2/hm2_7i90.0: IO Pin 040 (P2-33): IOPort
hm2/hm2_7i90.0: IO Pin 041 (P2-35): IOPort
hm2/hm2_7i90.0: IO Pin 042 (P2-37): IOPort
hm2/hm2_7i90.0: IO Pin 043 (P2-39): IOPort
hm2/hm2_7i90.0: IO Pin 044 (P2-41): IOPort
hm2/hm2_7i90.0: IO Pin 045 (P2-43): IOPort
hm2/hm2_7i90.0: IO Pin 046 (P2-45): IOPort
hm2/hm2_7i90.0: IO Pin 047 (P2-47): IOPort
hm2/hm2_7i90.0: IO Pin 048 (P3-01): IOPort
hm2/hm2_7i90.0: IO Pin 049 (P3-03): IOPort
hm2/hm2_7i90.0: IO Pin 050 (P3-05): IOPort
hm2/hm2_7i90.0: IO Pin 051 (P3-07): IOPort
hm2/hm2_7i90.0: IO Pin 052 (P3-09): IOPort
hm2/hm2_7i90.0: IO Pin 053 (P3-11): IOPort
hm2/hm2_7i90.0: IO Pin 054 (P3-13): IOPort
hm2/hm2_7i90.0: IO Pin 055 (P3-15): IOPort
hm2/hm2_7i90.0: IO Pin 056 (P3-17): IOPort
hm2/hm2_7i90.0: IO Pin 057 (P3-19): IOPort
hm2/hm2_7i90.0: IO Pin 058 (P3-21): IOPort
hm2/hm2_7i90.0: IO Pin 059 (P3-23): IOPort
hm2/hm2_7i90.0: IO Pin 060 (P3-25): IOPort
hm2/hm2_7i90.0: IO Pin 061 (P3-27): IOPort
hm2/hm2_7i90.0: IO Pin 062 (P3-29): IOPort
hm2/hm2_7i90.0: IO Pin 063 (P3-31): IOPort
hm2/hm2_7i90.0: IO Pin 064 (P3-33): IOPort
hm2/hm2_7i90.0: IO Pin 065 (P3-35): IOPort
hm2/hm2_7i90.0: IO Pin 066 (P3-37): IOPort
hm2/hm2_7i90.0: IO Pin 067 (P3-39): IOPort
hm2/hm2_7i90.0: IO Pin 068 (P3-41): IOPort
hm2/hm2_7i90.0: IO Pin 069 (P3-43): IOPort
hm2/hm2_7i90.0: IO Pin 070 (P3-45): IOPort
hm2/hm2_7i90.0: IO Pin 071 (P3-47): IOPort
hm2/hm2_7i90.0: registered


File Attachment:

File Name: rtAS5048_2...-06.comp
File Size:3 KB


I also attach the time diagram for the spi interface of the IC, because I don't know if it fits the bspi module, something confused here, some way to debug this controller, the chip I have tested with an arduino and it works, it is all I hope anxious
Attachments:

Please Log in or Create an account to join the conversation.

More
08 Jun 2021 23:09 #211559 by andypugh
You might need to set up the DPLL to trigger the BSPI transfers at the correct time, so that they are complete when you read them.

Does the incoming data look anything like what you expect? Be aware they byte and bit order might need to be switched.

Please Log in or Create an account to join the conversation.

More
12 Jun 2021 20:25 - 12 Jun 2021 20:26 #211887 by rbobey1989
hello again here without much progress, as I said before I have managed to load the DriverModule.comp in linuxcnc and I have connected a driver output pin to a u32 of the GUI, but it always shows all the bits in 1, I have been reading about DPLL and the only important parameter that I think it would be necessary to configure would be:

setp hm2_7i90.0.dpll.01.timer-us 8

8 us according to the documentation of hostmot2, if I did not misunderstand for 4 Mhz and 16 bits it would be 4 us and double this according to the consirection of the documentation is the value that we must load in timer-us, correct me if I am wrong.

I have some doubts:
The read and write functions when they run?
Are these functions not loading on a specific thread? (or are loaded into the servo-thread)

in the bufferedspi.vhd file the infifo: process is not sensitive to the idatacounter signal but to the odatacounter signal yes, this does not make sense at least to me.

In a previous photo of the timing-diagram of the AS5048 I have two times that I must consider [TL (350ns) and Th (50ns)] according to what I understand:
TL is time between CSn falling edge and clk rising edge
Th is time between last falling edge of CLK and rising edge of CSn
TL load it in the delay of the hm2_bspi_setup_chan function
Attached * .comp and * .hal, these are only tests, it is not a real machine, only the communication with the encoder is interested, thanks

File Attachment:

File Name: rtAS5048_2...-12.comp
File Size:2 KB

File Attachment:

File Name: test.hal
File Size:10 KB
Attachments:
Last edit: 12 Jun 2021 20:26 by rbobey1989.

Please Log in or Create an account to join the conversation.

More
12 Jun 2021 21:12 #211892 by PCW
The DPLL has nothing to do with high speed SPI timing but rather timing of events in the servo thread. For example: SSI encoders need to clock in their data at a somewhat slow rate (400 KHz is standard) Rather that have the servo thread wait for the data, the DPLL can schedule the start of the data transfer before the nominal servo thread thread activation. This is academic however as the BSPI cannot be triggered by the DPLL currently.

I dont think the BSPI can do a 350 ns CS delay, 150 ns is max with a 7I90s 100 MHz clocklow

Please Log in or Create an account to join the conversation.

More
15 Jun 2021 02:00 #212086 by rbobey1989
Good evening everyone after many long hours, I have found the solution, I have the AS5048A spi encoder working together with linuxcnc, the error almost went unnoticed, only change the type of CS decoding, this was done in the hostmot firmware in the file buferredspi.vhd, the value of the generic port:
gatedcs => false to true and the magic was done, I couldn't load the DBSPI module, I don't know why, it already has the parameter changed but it doesn't work for me, anyway only with this change I have managed to make it work therefore thanks to everyone and greetings
The following user(s) said Thank You: andypugh

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.122 seconds
Powered by Kunena Forum